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