program light;
var
o:array [1..2000000] of boolean;
n:longint;
f1,f2:text;
procedure init;
begin
assign(f1,'light.in'); reset(f1);
assign(f2,'light.out'); rewrite(f2);
readln(f1,n);
fillchar(o,sizeof(o),false);
end;
function pd(x:boolean):boolean;
begin
if x=true then pd:=false
else pd:=true;
end;
procedure play;
var a:double; flag,t,i,j:longint;
begin
for i:=1 to n do begin
readln(f1,a,t);
for j:=1 to t do
o[trunc(a*j)]:=pd(o[trunc(a*j)]);
end;
for i:=1 to 2000000 do
if o[i] then begin flag:=i; break; end;
writeln(f2,flag);
close(f2);
end;
begin
init;
play;
end.