var x,y: array[0..400000] of int64;
tx, ty: int64;
n, q, i, d, k, sq, g1, g2, gm: integer;
f,w: text;

begin
assign(f,'mountain.in');
reset(f);
readln(f,n,q);
x[0]:=0;
y[0]:=0;
for i:=1 to n do
begin
readln(f,d,k);
x[i]:=x[i-1]+d;
y[i]:=y[i-1]+d*k;
end;

assign(w,'mountain.out');
rewrite(w);

for sq:=1 to q do
begin
readln(f,tx,ty);
g1:=0;
g2:=n;
while g2-g1>1 do
begin
gm:=(g1+g2) div 2;
if tx>x[gm] then
g1:=gm else
if tx<x[gm] then
g2:=gm else
begin
g1:=gm-1;
g2:=gm+1;
break;
end;
end;

// going left
while (g1>0) do
begin
if y[g1-1]+(ty-y[g1-1])*(x[g1]-x[g1-1])/(tx-x[g1-1])<y[g1] then break;
g1:=g1-1;
end;
// going right
while (g2<n) do
begin
if y[g2+1]+(ty-y[g2+1])*(x[g2]-x[g2+1])/(tx-x[g2+1])<y[g2] then break;
g2:=g2+1;
end;

writeln(w,x[g1],' ',x[g2]);


end;

close(f);
close(w);

end.