var n,i,j,k,tot,ans:longint;
t:array[0..2000000]of boolean;
d:array[0..5000]of longint;
a:array[0..5000]of real;
x,y:real;
Begin
assign(input,'light.in');reset(input);
assign(output,'light.out');rewrite(output);
readln(n);
tot:=0;
fillchar(t,sizeof(t),false);
for i:=1 to n do
begin
readln(a[i],d[i]);
for j:=1 to d[i] do
begin
k:=trunc(a[i]*j);
if t[k] then t[k]:=false
else t[k]:=true;
end;
if tot<k then tot:=k;
end;
for i:=1 to tot do
if t[i] then begin ans:=i;break;end;
writeln(ans);
end.