program ex;
var
f:array[1..2000000] of boolean;
b:array[1..5000] of double;
c:array[1..5000] of longint;
i,j,t,n:longint;
procedure init;
begin
assign(input,'light.in');
assign(output,'light.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
begin
read(b[i]);
readln(c[i]);
end;
close(input);
for i:=1 to 2000000 do f[i]:=false;
end;
begin
init;
for i:=1 to n do
begin
for j:=1 to c[i] do
begin
t:=trunc(b[i]*j);
if f[t] then f[t]:=false else f[t]:=true;
end;
end;
for i:=1 to 2000000 do
begin
if f[i] then
begin
writeln(i);
close(output);
halt;
end;
end;
close(output);
end.