import bisect
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Q = list(map(int, next(sys.stdin).split()))
STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)]
D = [int(next(sys.stdin)) for _ in range(Q)]

ans = [-1] * Q
nexts = [-1] * Q

for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi

print('\n'.join(map(str, ans))) import bisect bisect import sys sys sys.setrecursionlimit(10000) sys.setrecursionlimit sys setrecursionlimit 10000 INF = float('inf') INF float('inf') float 'inf' N, Q = list(map(int, next(sys.stdin).split())) N list(map(int, next(sys.stdin).split())) list map(int, next(sys.stdin).split()) map int next(sys.stdin).split() (sys.stdin).split (sys.stdin) next sys.stdin sys stdin split Q list(map(int, next(sys.stdin).split())) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) list(map(int, next(sys.stdin).split())) list map(int, next(sys.stdin).split()) map int next(sys.stdin).split() (sys.stdin).split (sys.stdin) next sys.stdin sys stdin split STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)] STX [list(map(int, next(sys.stdin).split())) for _ in range(N)] int(next(sys.stdin)) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(next(sys.stdin)) int next(sys.stdin) next sys.stdin sys stdin D = [int(next(sys.stdin)) for _ in range(Q)] D [int(next(sys.stdin)) for _ in range(Q)] ans = [-1] * Q ans [-1] * Q [-1] -1 Q nexts = [-1] * Q nexts [-1] * Q [-1] -1 Q for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi s t x sorted(STX, key=lambda stx: (stx[2], stx[1])) sorted STX key=lambda stx: (stx[2], stx[1]) key lambda stx: (stx[2], stx[1]) (stx[2], stx[1]) stx[2] stx 2 stx[1] stx 1 stx lo = max(0, bisect.bisect_left(D, s - x)) lo max(0, bisect.bisect_left(D, s - x)) max 0 bisect.bisect_left(D, s - x) bisect.bisect_left bisect bisect_left D s - x s x hi = min(len(D), bisect.bisect_left(D, t - x)) hi min(len(D), bisect.bisect_left(D, t - x)) min len(D) len D bisect.bisect_left(D, t - x) bisect.bisect_left bisect bisect_left D t - x t x p = lo p lo while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi p < hi p hi if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi nexts[p] == -1 nexts[p] nexts p -1 ans[p] = x ans[p] ans p x nexts[p] = hi nexts[p] nexts p hi p += 1 p 1 prev = p prev p p = nexts[p] p nexts[p] nexts p nexts[prev] = hi nexts[prev] nexts prev hi print('\n'.join(map(str, ans))) print '\n'.join(map(str, ans)) '\n'.join '\n' join map(str, ans) map str ans STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)] [list(map(int, next(sys.stdin).split())) for _ in range(N)] STX ans = [-1] * Q [-1] * Q ans nexts = [-1] * Q [-1] * Q nexts p += 1 1 p Q = list(map(int, next(sys.stdin).split())) list(map(int, next(sys.stdin).split())) Q p = lo lo p D = [int(next(sys.stdin)) for _ in range(Q)] [int(next(sys.stdin)) for _ in range(Q)] D INF = float('inf') float('inf') INF lo = max(0, bisect.bisect_left(D, s - x)) max(0, bisect.bisect_left(D, s - x)) lo prev = p p prev N, Q = list(map(int, next(sys.stdin).split())) list(map(int, next(sys.stdin).split())) N p = nexts[p] nexts[p] p hi = min(len(D), bisect.bisect_left(D, t - x)) min(len(D), bisect.bisect_left(D, t - x)) hi
import bisect
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Q = list(map(int, next(sys.stdin).split()))
STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)]
D = [int(next(sys.stdin)) for _ in range(Q)]

ans = [-1] * Q
nexts = [-1] * Q

for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi

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