program light;
var
i,j,max,n,zt:longint;
z:real;
a:array[1..200000000] of real;
b:array[1..200000000] of boolean;
t:array[1..200000000] of integer;
begin
assign(input,'light.in');
assign(output,'light.out');
reset(input);
rewrite(output);
readln(n);
for i :=1 to n do
readln(a[i],t[i]);
max:=1;
fillchar(b,sizeof(b),false);
for i:=1 to n do
begin
for j:=1 to t[i] do
begin
z:=int(a[i]*j);
zt:=trunc(z);
if zt>max then max:=zt;
b[zt]:=not(b[zt]);
end;
end;
for i:=1 to max do
if b[i] then begin
writeln(i);
break;
end;
close(input);
close(output);
end.