# https://atcoder.jp/contests/abc128/submissions/8312583
# 写経

def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

    n, q = map(int, input().split())

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [(t - x, 0, x) for t, x in zip(T, X)]
    e.extend([(s - x, 1, x) for s, x in zip(S, X)])
    e.extend([(int(input()), 2, idx) for idx in range(q)])
    # e = [*((t - x, 0, x) for t, x in zip(T, X)),
    #      *((s - x, 1, x) for s, x in zip(S, X)),
    #      *((int(input()), 2, idx) for idx in range(q))
    #      ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

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


if __name__ == '__main__':
    solve() def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

    n, q = map(int, input().split())

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [(t - x, 0, x) for t, x in zip(T, X)]
    e.extend([(s - x, 1, x) for s, x in zip(S, X)])
    e.extend([(int(input()), 2, idx) for idx in range(q)])
    # e = [*((t - x, 0, x) for t, x in zip(T, X)),
    #      *((s - x, 1, x) for s, x in zip(S, X)),
    #      *((int(input()), 2, idx) for idx in range(q))
    #      ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

    print(*ret, sep='\n') solve from heapq import heappush, heappop from collections import defaultdict from operator import itemgetter import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline inf = 1 << 31 inf 1 << 31 1 31 n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q S = [0] * n S [0] * n [0] 0 n T = [0] * n T [0] * n [0] 0 n X = [0] * n X [0] * n [0] 0 n for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

     i range(n) range n S[i], T[i], X[i] = map(int, input().split()) S[i] S i map(int, input().split()) map int input().split() ().split () input split T[i] T i X[i] X i (t - x, 0, x) for t, x in zip(T, X) for t, x in zip(T, X) t x zip(T, X) zip T X for t, x in zip(T, X) (t - x, 0, x) t - x t x 0 x e = [(t - x, 0, x) for t, x in zip(T, X)] e [(t - x, 0, x) for t, x in zip(T, X)] (s - x, 1, x) for s, x in zip(S, X) for s, x in zip(S, X) s x zip(S, X) zip S X for s, x in zip(S, X) (s - x, 1, x) s - x s x 1 x e.extend([(s - x, 1, x) for s, x in zip(S, X)]) e.extend e extend [(s - x, 1, x) for s, x in zip(S, X)] (int(input()), 2, idx) for idx in range(q) for idx in range(q) idx range(q) range q for idx in range(q) (int(input()), 2, idx) int(input()) int input() input 2 idx e.extend([(int(input()), 2, idx) for idx in range(q)]) e.extend e extend [(int(input()), 2, idx) for idx in range(q)] e.sort(key=itemgetter(0)) e.sort e sort key=itemgetter(0) key itemgetter(0) itemgetter 0 cnt = defaultdict(int) cnt defaultdict(int) defaultdict int cnt[inf] = 1 cnt[inf] cnt inf 1 h = [inf] h [inf] inf ret = [-1] * q ret [-1] * q [-1] -1 q for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

     time type x e if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

     type == 0 type 0 cnt[x] -= 1 cnt[x] cnt x 1 elif type == 1:
            heappush(h, x)
            cnt[x] += 1
         type == 1 type 1 heappush(h, x) heappush h x cnt[x] += 1 cnt[x] cnt x 1 while not (cnt[h[0]]):
                heappop(h)
             not (cnt[h[0]]) cnt[h[0]] cnt h[0] h 0 heappop(h) heappop h curr = h[0] curr h[0] h 0 if curr != inf:
                ret[x] = curr

     curr != inf curr inf ret[x] = curr ret[x] ret x curr print(*ret, sep='\n') print *ret ret sep='\n' sep '\n' if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

    n, q = map(int, input().split())

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [(t - x, 0, x) for t, x in zip(T, X)]
    e.extend([(s - x, 1, x) for s, x in zip(S, X)])
    e.extend([(int(input()), 2, idx) for idx in range(q)])
    # e = [*((t - x, 0, x) for t, x in zip(T, X)),
    #      *((s - x, 1, x) for s, x in zip(S, X)),
    #      *((int(input()), 2, idx) for idx in range(q))
    #      ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

    print(*ret, sep='\n') def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

    n, q = map(int, input().split())

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [(t - x, 0, x) for t, x in zip(T, X)]
    e.extend([(s - x, 1, x) for s, x in zip(S, X)])
    e.extend([(int(input()), 2, idx) for idx in range(q)])
    # e = [*((t - x, 0, x) for t, x in zip(T, X)),
    #      *((s - x, 1, x) for s, x in zip(S, X)),
    #      *((int(input()), 2, idx) for idx in range(q))
    #      ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

    print(*ret, sep='\n') solve
# https://atcoder.jp/contests/abc128/submissions/8312583
# 写経

def solve():
    from heapq import heappush, heappop
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline

    inf = 1 << 31

    n, q = map(int, input().split())

    S = [0] * n
    T = [0] * n
    X = [0] * n
    for i in range(n):
        S[i], T[i], X[i] = map(int, input().split())

    e = [(t - x, 0, x) for t, x in zip(T, X)]
    e.extend([(s - x, 1, x) for s, x in zip(S, X)])
    e.extend([(int(input()), 2, idx) for idx in range(q)])
    # e = [*((t - x, 0, x) for t, x in zip(T, X)),
    #      *((s - x, 1, x) for s, x in zip(S, X)),
    #      *((int(input()), 2, idx) for idx in range(q))
    #      ]
    e.sort(key=itemgetter(0))
    # 安定ソートなので、0,1,2順になる（はず

    cnt = defaultdict(int)
    cnt[inf] = 1
    h = [inf]
    ret = [-1] * q
    for time, type, x in e:
        if type == 0:
            cnt[x] -= 1
        elif type == 1:
            heappush(h, x)
            cnt[x] += 1
        else:
            while not (cnt[h[0]]):
                heappop(h)
            curr = h[0]
            if curr != inf:
                ret[x] = curr

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


if __name__ == '__main__':
    solve()
