program zzn;
var
v:array[1..50000000]of boolean;
n,i,j,maxn,a:longint;
t:double;
procedure init;
begin
assign(input,'light.in');
reset(input);
assign(output,'light.out');
rewrite(output);
readln(n);
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure main;
begin
fillchar(v,sizeof(v),0);
maxn:=0;
for i:=1 to n do
begin
readln(t,a);
if trunc(t*a)>maxn then maxn:=trunc(t*a);
for j:=1 to a do
begin
v[trunc(j*t)]:=not(v[trunc(j*t)]);
end;
end;
for i:=1 to maxn do if v[i] then
begin
writeln(i);
exit;
end;
end;
begin
init;
main;
closef;
end.