program light(input,output);
const
maxl=2000010;
var
a:double;
n,t,i,j,tr:longint;
boo:array[1..maxl]of boolean;
begin
assign(input,'light.in');
reset(input);
assign(output,'light.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(a,t);
for j:=1 to t do
begin
tr:=trunc(a*j);
if tr>maxl then
break;
boo[tr]:=not boo[tr];
end;
end;
for i:=1 to maxl do
if boo[i] then
begin
writeln(i);
break;
end;
close(input);
close(output);
end.