import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop
from collections import defaultdict

N,Q = map(int,readline().split())
data = list(map(int,read().split()))
S = data[:3*N:3]
T = data[1:3*N:3]
X = data[2:3*N:3]
D = data[3*N:]

event = []
event += [(s-x,1,x) for x,s in zip(X,S)] # xに通行止めを1つ追加
event += [(t-x,2,x) for x,t in zip(X,T)] # xの通行止めを1つ削除
event += [(x,3,i) for i,x in enumerate(D)] # 最小の通行止めを答える

event.sort()

INF = 10**10
q = [INF]
counter = defaultdict(int)
counter[INF] = 1

answer = [None] * Q
for a,b,c in event:
    if b == 1:
        heappush(q,c)
        counter[c] += 1
    elif b == 2:
        counter[c] -= 1
    else:
        while counter[q[0]] == 0:
            heappop(q)
        x = q[0]
        if x == INF:
            x = -1
        answer[c] = x

print('\n'.join(map(str,answer))) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines from heapq import heappush, heappop from collections import defaultdict N,Q = map(int,readline().split()) N map(int,readline().split()) map int readline().split() ().split () readline split Q data = list(map(int,read().split())) data list(map(int,read().split())) list map(int,read().split()) map int read().split() ().split () read split S = data[:3*N:3] S data[:3*N:3] data :3*N:3 3*N 3 N 3 T = data[1:3*N:3] T data[1:3*N:3] data 1:3*N:3 1 3*N 3 N 3 X = data[2:3*N:3] X data[2:3*N:3] data 2:3*N:3 2 3*N 3 N 3 D = data[3*N:] D data[3*N:] data 3*N: 3*N 3 N event = [] event [] (s-x,1,x) for x,s in zip(X,S) for x,s in zip(X,S) x s zip(X,S) zip X S for x,s in zip(X,S) (s-x,1,x) s-x s x 1 x event += [(s-x,1,x) for x,s in zip(X,S)] event [(s-x,1,x) for x,s in zip(X,S)] (t-x,2,x) for x,t in zip(X,T) for x,t in zip(X,T) x t zip(X,T) zip X T for x,t in zip(X,T) (t-x,2,x) t-x t x 2 x event += [(t-x,2,x) for x,t in zip(X,T)] event [(t-x,2,x) for x,t in zip(X,T)] (x,3,i) for i,x in enumerate(D) for i,x in enumerate(D) i x enumerate(D) enumerate D for i,x in enumerate(D) (x,3,i) x 3 i event += [(x,3,i) for i,x in enumerate(D)] event [(x,3,i) for i,x in enumerate(D)] event.sort() event.sort event sort INF = 10**10 INF 10**10 10 10 q = [INF] q [INF] INF counter = defaultdict(int) counter defaultdict(int) defaultdict int counter[INF] = 1 counter[INF] counter INF 1 answer = [None] * Q answer [None] * Q [None] None Q for a,b,c in event:
    if b == 1:
        heappush(q,c)
        counter[c] += 1
    elif b == 2:
        counter[c] -= 1
    else:
        while counter[q[0]] == 0:
            heappop(q)
        x = q[0]
        if x == INF:
            x = -1
        answer[c] = x a b c event if b == 1:
        heappush(q,c)
        counter[c] += 1
    elif b == 2:
        counter[c] -= 1
    else:
        while counter[q[0]] == 0:
            heappop(q)
        x = q[0]
        if x == INF:
            x = -1
        answer[c] = x b == 1 b 1 heappush(q,c) heappush q c counter[c] += 1 counter[c] counter c 1 elif b == 2:
        counter[c] -= 1
     b == 2 b 2 counter[c] -= 1 counter[c] counter c 1 while counter[q[0]] == 0:
            heappop(q)
         counter[q[0]] == 0 counter[q[0]] counter q[0] q 0 0 heappop(q) heappop q x = q[0] x q[0] q 0 if x == INF:
            x = -1
         x == INF x INF x = -1 x -1 answer[c] = x answer[c] answer c x print('\n'.join(map(str,answer))) print '\n'.join(map(str,answer)) '\n'.join '\n' join map(str,answer) map str answer event += [(t-x,2,x) for x,t in zip(X,T)] [(t-x,2,x) for x,t in zip(X,T)] event event += [(x,3,i) for i,x in enumerate(D)] [(x,3,i) for i,x in enumerate(D)] event read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines D = data[3*N:] data[3*N:] D readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline event = [] [] event S = data[:3*N:3] data[:3*N:3] S q = [INF] [INF] q x = q[0] q[0] x data = list(map(int,read().split())) list(map(int,read().split())) data INF = 10**10 10**10 INF N,Q = map(int,readline().split()) map(int,readline().split()) N answer = [None] * Q [None] * Q answer x = -1 -1 x X = data[2:3*N:3] data[2:3*N:3] X Q = map(int,readline().split()) map(int,readline().split()) Q T = data[1:3*N:3] data[1:3*N:3] T counter = defaultdict(int) defaultdict(int) counter event += [(s-x,1,x) for x,s in zip(X,S)] [(s-x,1,x) for x,s in zip(X,S)] event
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from heapq import heappush, heappop
from collections import defaultdict

N,Q = map(int,readline().split())
data = list(map(int,read().split()))
S = data[:3*N:3]
T = data[1:3*N:3]
X = data[2:3*N:3]
D = data[3*N:]

event = []
event += [(s-x,1,x) for x,s in zip(X,S)] # xに通行止めを1つ追加
event += [(t-x,2,x) for x,t in zip(X,T)] # xの通行止めを1つ削除
event += [(x,3,i) for i,x in enumerate(D)] # 最小の通行止めを答える

event.sort()

INF = 10**10
q = [INF]
counter = defaultdict(int)
counter[INF] = 1

answer = [None] * Q
for a,b,c in event:
    if b == 1:
        heappush(q,c)
        counter[c] += 1
    elif b == 2:
        counter[c] -= 1
    else:
        while counter[q[0]] == 0:
            heappop(q)
        x = q[0]
        if x == INF:
            x = -1
        answer[c] = x

print('\n'.join(map(str,answer)))