program light;
var
a:array [1..5000] of double;
t:array [1..5000] of longint;
hash:array [1..20000000] of boolean;
v,i,j,n:longint;
begin
fillchar (a,sizeof(a),0);
fillchar (hash,sizeof(hash),0);
assign (input,'light.in');
reset (input);
readln (n);
for i:=1 to n do begin
readln (a[i],t[i]);
for j:=1 to t[i] do begin
v:=trunc(a[i]*j);
hash[v]:=not(hash[v]);
end;
end;
close (input);
assign (output,'light.out');
rewrite (output);
i:=1;
while hash[i]=false do inc(i);
writeln (i);
close (output);
end.