var
n,m,x,i,j,y,ans:longint;
l,r,w:array[0..1000000]of longint;
begin
assign(input,'max.in'); reset(input);
assign(output,'max.out'); rewrite(output);
readln(n,m);
for i:=1 to n do readln(l[i],r[i],w[i]);
for i:=1 to m do
begin
readln(x,y);
ans:=0;
for j:=1 to n do
if (l[j]>=x)and(r[j]<=y)and(w[j]>ans) then ans:=w[j];
writeln(ans);
end;
close(input);
close(output);
end.