def main():

    import sys

    from collections import defaultdict

    from heapq import heappop, heappush

    input = sys.stdin.readline



    N, Q = list(map(int, input().split()))

    used = defaultdict(int)

    tank = []

    

    p = []

    p_append = p.append

    for i in range(N):

        s, t, x = list(map(int, input().split()))

        p_append((s - x, x))

        p_append((t - x, -x))

    p.sort()



    cnt = 0

    for i in range(Q):

        d = int(eval(input()))

        while cnt <= len(p) - 1 and p[cnt][0] <= d:

            w = p[cnt][1]

            if w >= 0:

                used[w] += 1

                heappush(tank, w)

            else:

                used[-w] -= 1

            cnt += 1

        while True:

            if len(tank) == 0:

                print((-1))

                break

            kouho = tank[0]

            if used[kouho] > 0:

                print (kouho)

                break

            else:

                heappop(tank)



if __name__ == '__main__':

    main()
def main():

    import sys

    input = sys.stdin.readline

    from bisect import bisect_left



    N, Q = list(map(int, input().split()))

    c = []

    c_append = c.append

    for _ in range(N):

        s, t, x = list(map(int, input().split()))

        c_append((x, s, t))

    c.sort()



    D = [int(eval(input())) for _ in range(Q)]



    ans = [-1] * Q

    skip = [-1] * Q



    for x, s, t in c:

        left = bisect_left(D, s - x)

        right = bisect_left(D, t - x)

        while left < right:

            if skip[left] == -1:

                ans[left] = x

                skip[left] = right

                left += 1

            else:

                left = skip[left]



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



if __name__ == '__main__':

    main()
def main():
    import sys
    from collections import defaultdict
    from heapq import heappop, heappush

    input = sys.stdin.readline
    N, Q = list(map(int, input().split()))
    used = defaultdict(int)
    tank = []
    p = []
    p_append = p.append
    for i in range(N):
        s, t, x = list(map(int, input().split()))
        p_append((s - x, x))
        p_append((t - x, -x))
    p.sort()
    cnt = 0
    for i in range(Q):
        d = int(eval(input()))
        while cnt <= len(p) - 1 and p[cnt][0] <= d:
            w = p[cnt][1]
            if w >= 0:
                used[w] += 1
                heappush(tank, w)
            else:
                used[-w] -= 1
            cnt += 1
        while True:
            if len(tank) == 0:
                print((-1))
                break
            kouho = tank[0]
            if used[kouho] > 0:
                print(kouho)
                break
            else:
                heappop(tank)


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.readline
    from bisect import bisect_left

    N, Q = list(map(int, input().split()))
    c = []
    c_append = c.append
    for _ in range(N):
        s, t, x = list(map(int, input().split()))
        c_append((x, s, t))
    c.sort()
    D = [int(eval(input())) for _ in range(Q)]
    ans = [-1] * Q
    skip = [-1] * Q
    for x, s, t in c:
        left = bisect_left(D, s - x)
        right = bisect_left(D, t - x)
        while left < right:
            if skip[left] == -1:
                ans[left] = x
                skip[left] = right
                left += 1
            else:
                left = skip[left]
    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()

-    from collections import defaultdict -    from heapq import heappop, heappush +    from bisect import bisect_left + -    used = defaultdict(int) -    tank = [] -    p = [] -    p_append = p.append -    for i in range(N): +    c = [] +    c_append = c.append +    for _ in range(N): -        p_append((s - x, x)) -        p_append((t - x, -x)) -    p.sort() -    cnt = 0 -    for i in range(Q): -        d = int(eval(input())) -        while cnt <= len(p) - 1 and p[cnt][0] <= d: -            w = p[cnt][1] -            if w >= 0: -                used[w] += 1 -                heappush(tank, w) +        c_append((x, s, t)) +    c.sort() +    D = [int(eval(input())) for _ in range(Q)] +    ans = [-1] * Q +    skip = [-1] * Q +    for x, s, t in c: +        left = bisect_left(D, s - x) +        right = bisect_left(D, t - x) +        while left < right: +            if skip[left] == -1: +                ans[left] = x +                skip[left] = right +                left += 1 -                used[-w] -= 1 -            cnt += 1 -        while True: -            if len(tank) == 0: -                print((-1)) -                break -            kouho = tank[0] -            if used[kouho] > 0: -                print(kouho) -                break -            else: -                heappop(tank) +                left = skip[left] +    print(("\n".join(map(str, ans))))