import sys
input = sys.stdin.readline


n, q = map(int, input().split())
events = []
for _ in range(n):
    start, end, pos = map(int, input().split())
    events.append([start - pos, 1, pos])
    events.append([end - pos, 0, pos])

events.sort()

departures = [int(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 sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q events = [] events [] for _ in range(n):
    start, end, pos = map(int, input().split())
    events.append([start - pos, 1, pos])
    events.append([end - pos, 0, pos]) _ range(n) range n start, end, pos = map(int, input().split()) start map(int, input().split()) map int input().split() ().split () input split end pos events.append([start - pos, 1, pos]) events.append events append [start - pos, 1, pos] start - pos start pos 1 pos events.append([end - pos, 0, pos]) events.append events append [end - pos, 0, pos] end - pos end pos 0 pos events.sort() events.sort events sort int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input departures = [int(input()) for _ in range(q)] departures [int(input()) for _ in range(q)] idx = 0 idx 0 mini = 10**10 mini 10**10 10 10 mini_check = False mini_check False candidates = set() candidates set() set time, is_under_construction, pos = events[idx] time events[idx] events idx is_under_construction pos 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) departure 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]

     time <= departure 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
         is_under_construction candidates.add(pos) candidates.add candidates add pos if pos < mini:
                mini = pos
                mini_check = True
         pos < mini pos mini mini = pos mini pos mini_check = True mini_check True candidates.remove(pos) candidates.remove candidates remove pos if pos == mini:
                mini_check = False
         pos == mini pos mini mini_check = False mini_check False idx += 1 idx 1 if idx == 2 * n:
            time = float('INF')
            break
         idx == 2 * n idx 2 * n 2 n time = float('INF') time float('INF') float 'INF' break time, is_under_construction, pos = events[idx] time events[idx] events idx is_under_construction pos if not candidates:
        print(-1)
    else:
        if not mini_check:
            mini = min(candidates)
            mini_check = True
        print(mini) not candidates candidates print(-1) print -1 if not mini_check:
            mini = min(candidates)
            mini_check = True
         not mini_check mini_check mini = min(candidates) mini min(candidates) min candidates mini_check = True mini_check True print(mini) print mini idx = 0 0 idx mini_check = False False mini_check end, pos = map(int, input().split()) map(int, input().split()) end is_under_construction, pos = events[idx] events[idx] is_under_construction pos = events[idx] events[idx] pos events = [] [] events mini_check = True True mini_check input = sys.stdin.readline sys.stdin.readline input pos = map(int, input().split()) map(int, input().split()) pos candidates = set() set() candidates mini = pos pos mini time = float('INF') float('INF') time idx += 1 1 idx pos = events[idx] events[idx] pos mini = min(candidates) min(candidates) mini start, end, pos = map(int, input().split()) map(int, input().split()) start mini_check = True True mini_check q = map(int, input().split()) map(int, input().split()) q mini = 10**10 10**10 mini is_under_construction, pos = events[idx] events[idx] is_under_construction mini_check = False False mini_check departures = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] departures time, is_under_construction, pos = events[idx] events[idx] time time, is_under_construction, pos = events[idx] events[idx] time n, q = map(int, input().split()) map(int, input().split()) n
import sys
input = sys.stdin.readline


n, q = map(int, input().split())
events = []
for _ in range(n):
    start, end, pos = map(int, input().split())
    events.append([start - pos, 1, pos])
    events.append([end - pos, 0, pos])

events.sort()

departures = [int(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)
