import sys, heapq

input = sys.stdin.buffer.readline # 入出力高速化



def main():

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

    tl = [] # イベントタイムライン

    for _ in range(N):

        S, T, X = list(map(int, input().split()))

        tl.append((S-X, 1, X)) # insert

        tl.append((T-X, 0, X)) # erase

    for _ in range(Q):

        D = int(eval(input()))

        tl.append((D, 2, 0)) # min

    tl.sort()

    working = list() # 工事中

    todelete = list() # 削除用

    for t, c, x in tl:

        if c == 0: # erase

            heapq.heappush(todelete, x)

        elif c == 1: # insert

            heapq.heappush(working, x)

        else: # min

            while todelete and todelete[0] == working[0]:

                heapq.heappop(todelete)

                heapq.heappop(working)

            print((-1 if not working else working[0]))

    return

    

if __name__ == "__main__":

    main()

import sys

input = sys.stdin.buffer.readline # 入出力高速化



def main():

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

    tl = [] # イベントタイムライン

    for _ in range(N):

        S, T, X = list(map(int, input().split()))

        tl.append((S-X, 1, X)) # insert

        tl.append((T-X, 0, X)) # erase

    for _ in range(Q):

        D = int(eval(input()))

        tl.append((D, 2, 0)) # min

    tl.sort()

    working = set() # 工事中

    wcur = 0 # 工事中の区域の数

    curmin = -1

    flag = False

    for t, c, x in tl:

        if c == 0: # erase

            wcur -= 1

            working.remove(x)

            if x <= curmin:

                curmin = x

                flag = True

        elif c == 1: # insert

            wcur += 1

            working.add(x)

            if curmin < 0 or curmin >= x:

                curmin = x

                flag = False

        else: # min

            if wcur == 0:

                curmin = -1

                flag = False

            elif flag:

                curmin = min(working)

                flag = False

            print(curmin)

    return

    

if __name__ == "__main__":

    main()
import sys, heapq

input = sys.stdin.buffer.readline  # 入出力高速化


def main():
    N, Q = list(map(int, input().split()))
    tl = []  # イベントタイムライン
    for _ in range(N):
        S, T, X = list(map(int, input().split()))
        tl.append((S - X, 1, X))  # insert
        tl.append((T - X, 0, X))  # erase
    for _ in range(Q):
        D = int(eval(input()))
        tl.append((D, 2, 0))  # min
    tl.sort()
    working = list()  # 工事中
    todelete = list()  # 削除用
    for t, c, x in tl:
        if c == 0:  # erase
            heapq.heappush(todelete, x)
        elif c == 1:  # insert
            heapq.heappush(working, x)
        else:  # min
            while todelete and todelete[0] == working[0]:
                heapq.heappop(todelete)
                heapq.heappop(working)
            print((-1 if not working else working[0]))
    return


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.buffer.readline  # 入出力高速化


def main():
    N, Q = list(map(int, input().split()))
    tl = []  # イベントタイムライン
    for _ in range(N):
        S, T, X = list(map(int, input().split()))
        tl.append((S - X, 1, X))  # insert
        tl.append((T - X, 0, X))  # erase
    for _ in range(Q):
        D = int(eval(input()))
        tl.append((D, 2, 0))  # min
    tl.sort()
    working = set()  # 工事中
    wcur = 0  # 工事中の区域の数
    curmin = -1
    flag = False
    for t, c, x in tl:
        if c == 0:  # erase
            wcur -= 1
            working.remove(x)
            if x <= curmin:
                curmin = x
                flag = True
        elif c == 1:  # insert
            wcur += 1
            working.add(x)
            if curmin < 0 or curmin >= x:
                curmin = x
                flag = False
        else:  # min
            if wcur == 0:
                curmin = -1
                flag = False
            elif flag:
                curmin = min(working)
                flag = False
            print(curmin)
    return


if __name__ == "__main__":
    main()

-import sys, heapq +import sys -    working = list()  # 工事中 -    todelete = list()  # 削除用 +    working = set()  # 工事中 +    wcur = 0  # 工事中の区域の数 +    curmin = -1 +    flag = False -            heapq.heappush(todelete, x) +            wcur -= 1 +            working.remove(x) +            if x <= curmin: +                curmin = x +                flag = True -            heapq.heappush(working, x) +            wcur += 1 +            working.add(x) +            if curmin < 0 or curmin >= x: +                curmin = x +                flag = False -            while todelete and todelete[0] == working[0]: -                heapq.heappop(todelete) -                heapq.heappop(working) -            print((-1 if not working else working[0])) +            if wcur == 0: +                curmin = -1 +                flag = False +            elif flag: +                curmin = min(working) +                flag = False +            print(curmin)