program light;
var f:array[0..8000000]of qword;
t,k,m,n,i,j:longint;
a,b,p:qword;
r,s:real;
begin
assign(input,'light.in');
reset(input);
assign(output,'light.out');
rewrite(output);
readln(n);
repeat
dec(n);
readln(r,j);
for t:=1 to j do
begin
a:=trunc(r*t);
b:=a div 32;
if a mod 32=0 then
f[b]:=f[b] xor 1
else f[b]:=f[b]xor(1 shl (a mod 32));
end;
until n=0;
for t:=0 to 30 do
p:=p+(1 shl t);
for i:=0 to 8000000 do
if f[i]<>p then
for j:=0 to 31 do
if ((f[i] shr j)and 1)=1 then
begin
if j=0 then
b:=i*32
else b:=i*32+j;
writeln(b);
close(output);
halt;
end;
end.