N,Q = map(int,input().split())
STX = [tuple(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

starts = []
ends = []
for i,(s,t,x) in enumerate(STX):
    starts.append((s-x,i))
    ends.append((t-x,i))
starts.sort(key=lambda x:x[0], reverse=True)
ends.sort(key=lambda x:x[0], reverse=True)

import heapq
hq = []
heapq.heapify(hq)
delset = set()

ans = []
for d in D:
    while starts and starts[-1][0] <= d:
        _,i = starts.pop()
        x = STX[i][2]
        heapq.heappush(hq, x*N+i)
    while ends and ends[-1][0] <= d:
        _,i = ends.pop()
        delset.add(i)
    while hq:
        i = hq[0]%N
        if i in delset:
            heapq.heappop(hq)
        else:
            break
    if len(hq)==0:
        ans.append(-1)
    else:
        ans.append(hq[0]//N)

print(*ans, sep='\n') N,Q = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split Q tuple(map(int,input().split())) for i in range(N) for i in range(N) i range(N) range N for i in range(N) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split STX = [tuple(map(int,input().split())) for i in range(N)] STX [tuple(map(int,input().split())) for i in range(N)] int(input()) for i in range(Q) for i in range(Q) i range(Q) range Q for i in range(Q) int(input()) int input() input D = [int(input()) for i in range(Q)] D [int(input()) for i in range(Q)] starts = [] starts [] ends = [] ends [] for i,(s,t,x) in enumerate(STX):
    starts.append((s-x,i))
    ends.append((t-x,i)) i (s,t,x) s t x enumerate(STX) enumerate STX starts.append((s-x,i)) starts.append starts append (s-x,i) s-x s x i ends.append((t-x,i)) ends.append ends append (t-x,i) t-x t x i starts.sort(key=lambda x:x[0], reverse=True) starts.sort starts sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True ends.sort(key=lambda x:x[0], reverse=True) ends.sort ends sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True import heapq heapq hq = [] hq [] heapq.heapify(hq) heapq.heapify heapq heapify hq delset = set() delset set() set ans = [] ans [] for d in D:
    while starts and starts[-1][0] <= d:
        _,i = starts.pop()
        x = STX[i][2]
        heapq.heappush(hq, x*N+i)
    while ends and ends[-1][0] <= d:
        _,i = ends.pop()
        delset.add(i)
    while hq:
        i = hq[0]%N
        if i in delset:
            heapq.heappop(hq)
        else:
            break
    if len(hq)==0:
        ans.append(-1)
    else:
        ans.append(hq[0]//N) d D while starts and starts[-1][0] <= d:
        _,i = starts.pop()
        x = STX[i][2]
        heapq.heappush(hq, x*N+i)
     starts and starts[-1][0] <= d starts starts[-1][0] <= d starts[-1][0] [-1] starts -1 0 d _,i = starts.pop() _ starts.pop() starts.pop starts pop i x = STX[i][2] x STX[i][2] [i] STX i 2 heapq.heappush(hq, x*N+i) heapq.heappush heapq heappush hq x*N+i x*N x N i while ends and ends[-1][0] <= d:
        _,i = ends.pop()
        delset.add(i)
     ends and ends[-1][0] <= d ends ends[-1][0] <= d ends[-1][0] [-1] ends -1 0 d _,i = ends.pop() _ ends.pop() ends.pop ends pop i delset.add(i) delset.add delset add i while hq:
        i = hq[0]%N
        if i in delset:
            heapq.heappop(hq)
        else:
            break
     hq i = hq[0]%N i hq[0]%N hq[0] hq 0 N if i in delset:
            heapq.heappop(hq)
        else:
            break
     i in delset i delset heapq.heappop(hq) heapq.heappop heapq heappop hq break if len(hq)==0:
        ans.append(-1)
    else:
        ans.append(hq[0]//N) len(hq)==0 len(hq) len hq 0 ans.append(-1) ans.append ans append -1 ans.append(hq[0]//N) ans.append ans append hq[0]//N hq[0] hq 0 N print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' i = hq[0]%N hq[0]%N i ends = [] [] ends STX = [tuple(map(int,input().split())) for i in range(N)] [tuple(map(int,input().split())) for i in range(N)] STX _,i = ends.pop() ends.pop() _ ans = [] [] ans delset = set() set() delset starts = [] [] starts hq = [] [] hq x = STX[i][2] STX[i][2] x N,Q = map(int,input().split()) map(int,input().split()) N Q = map(int,input().split()) map(int,input().split()) Q D = [int(input()) for i in range(Q)] [int(input()) for i in range(Q)] D i = starts.pop() starts.pop() i _,i = starts.pop() starts.pop() _ i = ends.pop() ends.pop() i
N,Q = map(int,input().split())
STX = [tuple(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

starts = []
ends = []
for i,(s,t,x) in enumerate(STX):
    starts.append((s-x,i))
    ends.append((t-x,i))
starts.sort(key=lambda x:x[0], reverse=True)
ends.sort(key=lambda x:x[0], reverse=True)

import heapq
hq = []
heapq.heapify(hq)
delset = set()

ans = []
for d in D:
    while starts and starts[-1][0] <= d:
        _,i = starts.pop()
        x = STX[i][2]
        heapq.heappush(hq, x*N+i)
    while ends and ends[-1][0] <= d:
        _,i = ends.pop()
        delset.add(i)
    while hq:
        i = hq[0]%N
        if i in delset:
            heapq.heappop(hq)
        else:
            break
    if len(hq)==0:
        ans.append(-1)
    else:
        ans.append(hq[0]//N)

print(*ans, sep='\n')