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