var
n,t,i,z,min,j,max:longint;
s:real;
f:array[0..20000000]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(s,t);
for j:=1 to t do
begin
z:=trunc(j*s);
if not f[z] then f[z]:=true
else f[z]:=false;
if z>max then max:=z;
if z<min then min:=z;
end;
end;
for i:=min to max do
if f[i] then
begin
writeln(i);
break;
end;
close(input);
close(output);
end.