import sys, collections, heapq
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()

def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0

if __name__ == "__main__":
    solve() import sys, collections, heapq sys collections heapq def single_input(F): return F.readline().strip("\n") single_input F F def line_input(F): return F.readline().strip("\n").split() line_input F F def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0 solve F = sys.stdin F sys.stdin sys stdin N, Q = map(int, line_input(F)) N map(int, line_input(F)) map int line_input(F) line_input F Q event = [] event [] for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
     i range(N) range N s, t, x = map(int, line_input(F)) s map(int, line_input(F)) map int line_input(F) line_input F t x event.append((s-x, 1, x)) event.append event append (s-x, 1, x) s-x s x 1 x event.append((t-x,-1, x)) event.append event append (t-x,-1, x) t-x t x -1 x for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
     i range(Q) range Q d = int(single_input(F)) d int(single_input(F)) int single_input(F) single_input F event.append((d, 2, d)) event.append event append (d, 2, d) d 2 d event.sort() event.sort event sort candidate = [] candidate [] heapq.heapify(candidate) heapq.heapify heapq heapify candidate stop = collections.defaultdict(int) stop collections.defaultdict(int) collections.defaultdict collections defaultdict int ans = "" ans "" for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
     time parameter co event if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
     parameter == 1 parameter 1 heapq.heappush(candidate, co) heapq.heappush heapq heappush candidate co stop[co] += 1 stop[co] stop co 1 elif parameter == -1:
            stop[co] -= 1
         parameter == -1 parameter -1 stop[co] -= 1 stop[co] stop co 1 while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
     candidate x = heapq.heappop(candidate) x heapq.heappop(candidate) heapq.heappop heapq heappop candidate if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
             stop[x] > 0 stop[x] stop x 0 heapq.heappush(candidate, x) heapq.heappush heapq heappush candidate x ans += str(x) + "\n" ans str(x) + "\n" str(x) str x "\n" break print(ans) print ans return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def single_input(F): return F.readline().strip("\n") def single_input(F): return F.readline().strip("\n") single_input def line_input(F): return F.readline().strip("\n").split() def line_input(F): return F.readline().strip("\n").split() line_input def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0 def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0 solve
import sys, collections, heapq
def single_input(F): return F.readline().strip("\n")
def line_input(F): return F.readline().strip("\n").split()

def solve():
    F = sys.stdin
    N, Q = map(int, line_input(F))
    event = []
    for i in range(N):
        s, t, x = map(int, line_input(F))
        event.append((s-x, 1, x))
        event.append((t-x,-1, x))
    for i in range(Q):
        d = int(single_input(F))
        event.append((d, 2, d))
    event.sort()
    candidate = []
    heapq.heapify(candidate)
    stop = collections.defaultdict(int)
    ans = ""
    for time, parameter, co in event:
        if parameter == 1:
            heapq.heappush(candidate, co)
            stop[co] += 1
        elif parameter == -1:
            stop[co] -= 1
        else:
            while candidate:
                x = heapq.heappop(candidate)
                if stop[x] > 0:
                    heapq.heappush(candidate, x)
                    ans += str(x) + "\n"
                    break
            else: ans += "-1\n"
    print(ans)

    return 0

if __name__ == "__main__":
    solve()