{灯
哈希表
Author: yangbohua
Time: 2010-11-16 09:09}
program light;
var
f:array[0..20000000] of boolean;
n,i,j,p,t:longint;
a,q:double;
begin
assign(input,'light.in');
reset(input);
assign(output,'light.out');
rewrite(output);
readln(n);
fillchar(f,sizeof(f),false);
for i:=1 to n do
begin
readln(a,t);
q:=0;
for j:=1 to t do
begin
q:=q+a;
p:=trunc(q);
if f[p]
then f[p]:=false
else f[p]:=true;
end;
end;
i:=1;
while f[i]=false do
inc(i);
writeln(i);
close(input);
close(output);
end.