from heapq import heappush, heappop
N,Q,*L = map(int, open(0).read().split())
X = L[:3*N]
D = L[3*N:]
ls = []
for s,t,x in zip(*[iter(X)]*3):
  ls.append((s-x,1,x))
  ls.append((t-x,0,x))
for i,d in enumerate(D):
  ls.append((d,2,i))
ls.sort()
ans = [0]*Q
S = set()
hq = []
for a,b,c in ls:
  if b==0:
    S.remove(c)
  elif b==1:
    S.add(c)
    heappush(hq,c)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    ans[c] = hq[0] if hq else -1
print('\n'.join(map(str,ans))) from heapq import heappush, heappop N,Q,*L = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split Q *L L X = L[:3*N] X L[:3*N] L :3*N 3*N 3 N D = L[3*N:] D L[3*N:] L 3*N: 3*N 3 N ls = [] ls [] for s,t,x in zip(*[iter(X)]*3):
  ls.append((s-x,1,x))
  ls.append((t-x,0,x)) s t x zip(*[iter(X)]*3) zip *[iter(X)]*3 [iter(X)]*3 [iter(X)] iter(X) iter X 3 ls.append((s-x,1,x)) ls.append ls append (s-x,1,x) s-x s x 1 x ls.append((t-x,0,x)) ls.append ls append (t-x,0,x) t-x t x 0 x for i,d in enumerate(D):
  ls.append((d,2,i)) i d enumerate(D) enumerate D ls.append((d,2,i)) ls.append ls append (d,2,i) d 2 i ls.sort() ls.sort ls sort ans = [0]*Q ans [0]*Q [0] 0 Q S = set() S set() set hq = [] hq [] for a,b,c in ls:
  if b==0:
    S.remove(c)
  elif b==1:
    S.add(c)
    heappush(hq,c)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    ans[c] = hq[0] if hq else -1 a b c ls if b==0:
    S.remove(c)
  elif b==1:
    S.add(c)
    heappush(hq,c)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    ans[c] = hq[0] if hq else -1 b==0 b 0 S.remove(c) S.remove S remove c elif b==1:
    S.add(c)
    heappush(hq,c)
   b==1 b 1 S.add(c) S.add S add c heappush(hq,c) heappush hq c while hq and hq[0] not in S:
      heappop(hq)
     hq and hq[0] not in S hq hq[0] not in S hq[0] hq 0 S heappop(hq) heappop hq ans[c] = hq[0] if hq else -1 ans[c] ans c hq[0] if hq else -1 hq hq[0] hq 0 -1 print('\n'.join(map(str,ans))) print '\n'.join(map(str,ans)) '\n'.join '\n' join map(str,ans) map str ans N,Q,*L = map(int, open(0).read().split()) map(int, open(0).read().split()) N ans = [0]*Q [0]*Q ans ls = [] [] ls X = L[:3*N] L[:3*N] X hq = [] [] hq S = set() set() S Q,*L = map(int, open(0).read().split()) map(int, open(0).read().split()) Q D = L[3*N:] L[3*N:] D
from heapq import heappush, heappop
N,Q,*L = map(int, open(0).read().split())
X = L[:3*N]
D = L[3*N:]
ls = []
for s,t,x in zip(*[iter(X)]*3):
  ls.append((s-x,1,x))
  ls.append((t-x,0,x))
for i,d in enumerate(D):
  ls.append((d,2,i))
ls.sort()
ans = [0]*Q
S = set()
hq = []
for a,b,c in ls:
  if b==0:
    S.remove(c)
  elif b==1:
    S.add(c)
    heappush(hq,c)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    ans[c] = hq[0] if hq else -1
print('\n'.join(map(str,ans)))