program aa;
var
i,j:longint;
f:text;
c:integer;
cr:array[1..5000] of integer;
br:array[1..5000] of real;
ar:array[1..200000] of integer;
function bian(a:real;b:integer):integer;
var
i,j,k:integer;
begin
for i:=1 to b do
begin
k:=trunc(i*a);
if ar[k]=0 then ar[k]:=1 else
ar[k]:=0;
end;
end;
begin
for i:=1 to 200000 do
ar[i]:=0;
assign(f,'light.in');
reset(f);
readln(f,c);
for i:=1 to c do
begin
readln(f,br[i],cr[i]);
bian(br[i],cr[i]);
end;
assign(f,'light.out');
rewrite(f);
for i:=1 to 200000 do
if ar[i]=1 then
begin
write(f,i);
break;
end;
close(f);
end.