import sys

input = sys.stdin.readline





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

events = []

for _ in range(n):

    start, end, pos = list(map(int, input().split()))

    events.append([start - pos, 1, pos])

    events.append([end - pos, 0, pos])



events.sort()



departures = [int(eval(input())) for _ in range(q)]



idx = 0

mini = 10**10

mini_check = False

candidates = set()

time, is_under_construction, pos = events[idx]

for departure in departures:

    while time <= departure:

        if is_under_construction:

            candidates.add(pos)

            if pos < mini:

                mini = pos

                mini_check = True

        else:

            candidates.remove(pos)

            if pos == mini:

                mini_check = False

        idx += 1

        if idx == 2 * n:

            time = float('INF')

            break

        time, is_under_construction, pos = events[idx]



    if not candidates:

        print((-1))

    else:

        if not mini_check:

            mini = min(candidates)

            mini_check = True

        print(mini)

import bisect

import sys

input = sys.stdin.readline





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

events = [list(map(int, input().split())) for _ in range(n)]

events.sort(key=lambda x: x[2])



departures = [int(eval(input())) for _ in range(q)]





ans = ['-1'] * q

skip = [-1] * q



for start, end, pos in events:

    left = bisect.bisect_left(departures, start-pos)

    right = bisect.bisect_left(departures, end-pos)



    while left < right:

        if skip[left] == -1:

            ans[left] = str(pos)

            skip[left] = right

            left += 1



        else:

            left = skip[left]



print(('\n'.join(ans)))
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
events = []
for _ in range(n):
    start, end, pos = list(map(int, input().split()))
    events.append([start - pos, 1, pos])
    events.append([end - pos, 0, pos])
events.sort()
departures = [int(eval(input())) for _ in range(q)]
idx = 0
mini = 10**10
mini_check = False
candidates = set()
time, is_under_construction, pos = events[idx]
for departure in departures:
    while time <= departure:
        if is_under_construction:
            candidates.add(pos)
            if pos < mini:
                mini = pos
                mini_check = True
        else:
            candidates.remove(pos)
            if pos == mini:
                mini_check = False
        idx += 1
        if idx == 2 * n:
            time = float("INF")
            break
        time, is_under_construction, pos = events[idx]
    if not candidates:
        print((-1))
    else:
        if not mini_check:
            mini = min(candidates)
            mini_check = True
        print(mini)

import bisect
import sys

input = sys.stdin.readline
n, q = list(map(int, input().split()))
events = [list(map(int, input().split())) for _ in range(n)]
events.sort(key=lambda x: x[2])
departures = [int(eval(input())) for _ in range(q)]
ans = ["-1"] * q
skip = [-1] * q
for start, end, pos in events:
    left = bisect.bisect_left(departures, start - pos)
    right = bisect.bisect_left(departures, end - pos)
    while left < right:
        if skip[left] == -1:
            ans[left] = str(pos)
            skip[left] = right
            left += 1
        else:
            left = skip[left]
print(("\n".join(ans)))

+import bisect -events = [] -for _ in range(n): -    start, end, pos = list(map(int, input().split())) -    events.append([start - pos, 1, pos]) -    events.append([end - pos, 0, pos]) -events.sort() +events = [list(map(int, input().split())) for _ in range(n)] +events.sort(key=lambda x: x[2]) -idx = 0 -mini = 10**10 -mini_check = False -candidates = set() -time, is_under_construction, pos = events[idx] -for departure in departures: -    while time <= departure: -        if is_under_construction: -            candidates.add(pos) -            if pos < mini: -                mini = pos -                mini_check = True +ans = ["-1"] * q +skip = [-1] * q +for start, end, pos in events: +    left = bisect.bisect_left(departures, start - pos) +    right = bisect.bisect_left(departures, end - pos) +    while left < right: +        if skip[left] == -1: +            ans[left] = str(pos) +            skip[left] = right +            left += 1 -            candidates.remove(pos) -            if pos == mini: -                mini_check = False -        idx += 1 -        if idx == 2 * n: -            time = float("INF") -            break -        time, is_under_construction, pos = events[idx] -    if not candidates: -        print((-1)) -    else: -        if not mini_check: -            mini = min(candidates) -            mini_check = True -        print(mini) +            left = skip[left] +print(("\n".join(ans)))