import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

N, Q = map(int, input().split())
INF = float('inf')

events = []
for i in range(N):
    S, T, X = map(int, input().split())
    events.append((S - X, 0, X))
    events.append((T - X, 1, X))

for _ in range(Q):
    events.append((int(input()), 2, 0))

events.sort()

cnt = defaultdict(int)
cnt[INF] += 1
que = [INF]

for t, flag, x in events:
    if flag == 0:
        if cnt[x] == 0:
            heappush(que, x)
        cnt[x] += 1
    elif flag == 1:
        cnt[x] -= 1
    else:
        while cnt[que[0]] == 0:
            heappop(que)
        print(que[0] if que[0] != INF else -1)
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import defaultdict from heapq import heappop, heappush N, Q = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split Q INF = float('inf') INF float('inf') float 'inf' events = [] events [] for i in range(N):
    S, T, X = map(int, input().split())
    events.append((S - X, 0, X))
    events.append((T - X, 1, X)) i range(N) range N S, T, X = map(int, input().split()) S map(int, input().split()) map int input().split() ().split () input split T X events.append((S - X, 0, X)) events.append events append (S - X, 0, X) S - X S X 0 X events.append((T - X, 1, X)) events.append events append (T - X, 1, X) T - X T X 1 X for _ in range(Q):
    events.append((int(input()), 2, 0)) _ range(Q) range Q events.append((int(input()), 2, 0)) events.append events append (int(input()), 2, 0) int(input()) int input() input 2 0 events.sort() events.sort events sort cnt = defaultdict(int) cnt defaultdict(int) defaultdict int cnt[INF] += 1 cnt[INF] cnt INF 1 que = [INF] que [INF] INF for t, flag, x in events:
    if flag == 0:
        if cnt[x] == 0:
            heappush(que, x)
        cnt[x] += 1
    elif flag == 1:
        cnt[x] -= 1
    else:
        while cnt[que[0]] == 0:
            heappop(que)
        print(que[0] if que[0] != INF else -1) t flag x events if flag == 0:
        if cnt[x] == 0:
            heappush(que, x)
        cnt[x] += 1
    elif flag == 1:
        cnt[x] -= 1
    else:
        while cnt[que[0]] == 0:
            heappop(que)
        print(que[0] if que[0] != INF else -1) flag == 0 flag 0 if cnt[x] == 0:
            heappush(que, x)
         cnt[x] == 0 cnt[x] cnt x 0 heappush(que, x) heappush que x cnt[x] += 1 cnt[x] cnt x 1 elif flag == 1:
        cnt[x] -= 1
     flag == 1 flag 1 cnt[x] -= 1 cnt[x] cnt x 1 while cnt[que[0]] == 0:
            heappop(que)
         cnt[que[0]] == 0 cnt[que[0]] cnt que[0] que 0 0 heappop(que) heappop que print(que[0] if que[0] != INF else -1) print que[0] if que[0] != INF else -1 que[0] != INF que[0] que 0 INF que[0] que 0 -1 X = map(int, input().split()) map(int, input().split()) X INF = float('inf') float('inf') INF cnt = defaultdict(int) defaultdict(int) cnt N, Q = map(int, input().split()) map(int, input().split()) N input = sys.stdin.readline sys.stdin.readline input T, X = map(int, input().split()) map(int, input().split()) T que = [INF] [INF] que S, T, X = map(int, input().split()) map(int, input().split()) S Q = map(int, input().split()) map(int, input().split()) Q events = [] [] events
import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

N, Q = map(int, input().split())
INF = float('inf')

events = []
for i in range(N):
    S, T, X = map(int, input().split())
    events.append((S - X, 0, X))
    events.append((T - X, 1, X))

for _ in range(Q):
    events.append((int(input()), 2, 0))

events.sort()

cnt = defaultdict(int)
cnt[INF] += 1
que = [INF]

for t, flag, x in events:
    if flag == 0:
        if cnt[x] == 0:
            heappush(que, x)
        cnt[x] += 1
    elif flag == 1:
        cnt[x] -= 1
    else:
        while cnt[que[0]] == 0:
            heappop(que)
        print(que[0] if que[0] != INF else -1)

