program light;
var
i,j,k:longint;
n,m:longint;
a:array[1..2000000]of boolean;
o:extended;
begin
assign(input,'light.in');
reset(input);
assign(output,'light.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(o,m);
for j:=1 to m do
begin
if o*j>2000000 then break;
k:=trunc(o*j);
a[k]:=not a[k];
end;
end;
for i:=1 to 2000000 do
if a[i] then
begin
writeln(i);
break;
end;
close(input);
close(output);
end.