from heapq import heapify, heappush, heappop 

INF = 1001001001

N, Q = map(int, input().split())
STXs = [tuple(map(int, input().split())) for _ in range(N)]
Ds = [int(input()) for _ in range(Q)]

#S-X, T-X, X
future_block = [(S - X, T - X, X) for S, T, X in STXs]
future_block.append((INF, INF, INF)) #sentinel
heapify(future_block)

#T-X, X
current_block = [(INF, INF)] #sentinel
current_min_pair = (INF, INF)

for D in Ds:
    while future_block[0][0] <= D:
        s_x, t_x, x = heappop(future_block)
        if current_min_pair[1] > x:
            current_min_pair = (t_x, x)
        heappush(current_block, (t_x, x))
    
    search_min_flg = False
    while current_block[0][0] <= D:
        if current_min_pair == heappop(current_block):
            search_min_flg = True
    if search_min_flg:
        current_min_pair = min(current_block, key = lambda t: t[1])

    print(-1 if current_min_pair[1] == INF else current_min_pair[1]) from heapq import heapify, heappush, heappop INF = 1001001001 INF 1001001001 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 _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split STXs = [tuple(map(int, input().split())) for _ in range(N)] STXs [tuple(map(int, input().split())) for _ in range(N)] int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input Ds = [int(input()) for _ in range(Q)] Ds [int(input()) for _ in range(Q)] (S - X, T - X, X) for S, T, X in STXs for S, T, X in STXs S T X STXs for S, T, X in STXs (S - X, T - X, X) S - X S X T - X T X X future_block = [(S - X, T - X, X) for S, T, X in STXs] future_block [(S - X, T - X, X) for S, T, X in STXs] future_block.append((INF, INF, INF)) future_block.append future_block append (INF, INF, INF) INF INF INF heapify(future_block) heapify future_block current_block = [(INF, INF)] current_block [(INF, INF)] (INF, INF) INF INF current_min_pair = (INF, INF) current_min_pair (INF, INF) INF INF for D in Ds:
    while future_block[0][0] <= D:
        s_x, t_x, x = heappop(future_block)
        if current_min_pair[1] > x:
            current_min_pair = (t_x, x)
        heappush(current_block, (t_x, x))
    
    search_min_flg = False
    while current_block[0][0] <= D:
        if current_min_pair == heappop(current_block):
            search_min_flg = True
    if search_min_flg:
        current_min_pair = min(current_block, key = lambda t: t[1])

    print(-1 if current_min_pair[1] == INF else current_min_pair[1]) D Ds while future_block[0][0] <= D:
        s_x, t_x, x = heappop(future_block)
        if current_min_pair[1] > x:
            current_min_pair = (t_x, x)
        heappush(current_block, (t_x, x))
    
     future_block[0][0] <= D future_block[0][0] [0] future_block 0 0 D s_x, t_x, x = heappop(future_block) s_x heappop(future_block) heappop future_block t_x x if current_min_pair[1] > x:
            current_min_pair = (t_x, x)
         current_min_pair[1] > x current_min_pair[1] current_min_pair 1 x current_min_pair = (t_x, x) current_min_pair (t_x, x) t_x x heappush(current_block, (t_x, x)) heappush current_block (t_x, x) t_x x search_min_flg = False search_min_flg False while current_block[0][0] <= D:
        if current_min_pair == heappop(current_block):
            search_min_flg = True
     current_block[0][0] <= D current_block[0][0] [0] current_block 0 0 D if current_min_pair == heappop(current_block):
            search_min_flg = True
     current_min_pair == heappop(current_block) current_min_pair heappop(current_block) heappop current_block search_min_flg = True search_min_flg True if search_min_flg:
        current_min_pair = min(current_block, key = lambda t: t[1])

     search_min_flg current_min_pair = min(current_block, key = lambda t: t[1]) current_min_pair min(current_block, key = lambda t: t[1]) min current_block key = lambda t: t[1] key lambda t: t[1] t[1] t 1 t print(-1 if current_min_pair[1] == INF else current_min_pair[1]) print -1 if current_min_pair[1] == INF else current_min_pair[1] current_min_pair[1] == INF current_min_pair[1] current_min_pair 1 INF -1 current_min_pair[1] current_min_pair 1 INF = 1001001001 1001001001 INF s_x, t_x, x = heappop(future_block) heappop(future_block) s_x t_x, x = heappop(future_block) heappop(future_block) t_x search_min_flg = False False search_min_flg Ds = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] Ds x = heappop(future_block) heappop(future_block) x search_min_flg = True True search_min_flg current_min_pair = min(current_block, key = lambda t: t[1]) min(current_block, key = lambda t: t[1]) current_min_pair N, Q = map(int, input().split()) map(int, input().split()) N Q = map(int, input().split()) map(int, input().split()) Q current_block = [(INF, INF)] [(INF, INF)] current_block current_min_pair = (INF, INF) (INF, INF) current_min_pair STXs = [tuple(map(int, input().split())) for _ in range(N)] [tuple(map(int, input().split())) for _ in range(N)] STXs future_block = [(S - X, T - X, X) for S, T, X in STXs] [(S - X, T - X, X) for S, T, X in STXs] future_block current_min_pair = (t_x, x) (t_x, x) current_min_pair
from heapq import heapify, heappush, heappop 

INF = 1001001001

N, Q = map(int, input().split())
STXs = [tuple(map(int, input().split())) for _ in range(N)]
Ds = [int(input()) for _ in range(Q)]

#S-X, T-X, X
future_block = [(S - X, T - X, X) for S, T, X in STXs]
future_block.append((INF, INF, INF)) #sentinel
heapify(future_block)

#T-X, X
current_block = [(INF, INF)] #sentinel
current_min_pair = (INF, INF)

for D in Ds:
    while future_block[0][0] <= D:
        s_x, t_x, x = heappop(future_block)
        if current_min_pair[1] > x:
            current_min_pair = (t_x, x)
        heappush(current_block, (t_x, x))
    
    search_min_flg = False
    while current_block[0][0] <= D:
        if current_min_pair == heappop(current_block):
            search_min_flg = True
    if search_min_flg:
        current_min_pair = min(current_block, key = lambda t: t[1])

    print(-1 if current_min_pair[1] == INF else current_min_pair[1])
