CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop, heapify
from collections import defaultdict
import copy
 
N,Q=list(map(int, sys.stdin.readline().split()))
 
S=[]
event=[]
for _ in range(N):
	s,t,x=list(map(int, sys.stdin.readline().split()))
	event.append(  ( s-x ,1, x) )	#Start
	event.append(  ( t-x,-1, x) )	#End


for i in range(Q):
	d=int(sys.stdin.readline().strip())
	event.append(  (d ,0, i) )

event.sort(key=lambda x:(x[0]) )

stop=set()

ans=defaultdict(lambda: -1)
is_stop=False
minstop=float("inf")


for s,flag,x in event:
	if flag==1:
		stop.add(x)
		if x<minstop:
			minstop=x
			is_stop=True
	elif flag==-1:
		try:
			stop.remove(x)
		except:
			pass
		if minstop==x:
			is_stop=False
	elif flag==0:
		if stop:
			if not is_stop:
				minstop=min(stop)
				is_stop=True
			ans[x]=minstop
		else:
			ans[x]=-1


for i in range(Q):
	print((ans[i]))


# Optimized solution
# -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right

N,Q=list(map(int, sys.stdin.readline().split()))

S=[]
event=[]	#x, s, t
for _ in range(N):
	s,t,x=list(map(int, sys.stdin.readline().split()))
	heappush( event, (x, max(0,s-x) , max(0,t-1-x)) )


D=[ int(sys.stdin.readline().strip()) for _ in range(Q) ]
D.sort()
ans=[ float("inf") for _ in range(Q) ]

Next=[ i+1 for i in range(Q) ]	#Next


while event:
	x,s,t=heappop(event)
	start=bisect_left(D,s)
	end=bisect_right(D,t)

	i=start
	while i<end:
		ans[i]=min(ans[i],x)
		next=Next[i]
		Next[i]=end
		i=next

for x in ans:
	if x==float("inf"):
		print(-1)
	else:
		print(x)
# Original solution
import sys
input = sys.stdin.readline
from heapq import heappop,heappush

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

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x))
  task.append((s-x,1,x))

for i in range(Q):
  d = int(eval(input()))
  task.append((d,2,i))
answer = [-1]*Q

task.sort()

se = set()
se_hp = []
for a,b,c in task:
  if not b:
    se.remove(c)
  elif b&1:
    se.add(c)
    heappush(se_hp,c)
  else:
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

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


# Optimized solution
import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,Q = list(map(int,input().split()))
    event = []
    
    for _ in range(N):
        s,t,x = list(map(int,input().split()))
        event.append((s-x,1,x))
        event.append((t-x,0,x))
        
    for i in range(Q):
        a = int(eval(input()))
        event.append((a,2,i))
    
    event.sort()
    ans = [-1]*Q
    use = set()
    stop = []
    
    for a,b,c in event:
        if b == 1:
            use.add(c)
            heapq.heappush(stop,c)
        elif b == 0:
            use.remove(c)
        else:
            while stop and stop[0] not in use:
                heapq.heappop(stop)
            ans[c] = -1 if len(stop) == 0 else stop[0]
    
    for num in ans:
        print(num)

if __name__ == "__main__":
    main()
# Original solution
import bisect

n, q = list(map(int, input().split()))
rws = [list(map(int, input().split())) for _ in range(n)]
ds = [int(eval(input())) for _ in range(q)]

rws.sort(key = lambda x: x[2])
ans = [-1 for _ in range(q)]
for rw in rws:
	st = bisect.bisect_left(ds, rw[0] - rw[2])
	en = bisect.bisect_left(ds, rw[1] - rw[2])
	while st < en:
		if ans[st] == -1:
			ans[st] = rw[2]
		st += 1

for a in ans:
	print(a)

# Optimized solution
import bisect

n, q = list(map(int, input().split()))
rws = [list(map(int, input().split())) for _ in range(n)]
ds = [int(eval(input())) for _ in range(q)]

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

ans = [-1 for _ in range(q)]
nxt = [-1 for _ in range(q)]
for rw in rws:
	st = bisect.bisect_left(ds, rw[0] - rw[2])
	en = bisect.bisect_left(ds, rw[1] - rw[2])
	while st < en:
		if nxt[st] == -1:
			ans[st] = rw[2]
			nxt[st] = en
			st += 1
		else:
			st = nxt[st]

for a in ans:
	print(a)
# Original solution
class BIT():
	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def getsum(self, k):
		ret = 0
		while k:
			ret += self.bit[k]
			k -= k & -k
		return ret

	def p_sum(self, i, j):
		return self.getsum(j) - self.getsum(i - 1)

	def add(self, k, x):
		while k <= self.n:
			self.bit[k] += x
			k += k & -k

	def bisect(self, x):
		i, m = 0, 1 << (self.n.bit_length() - 1)
		while m:
			t = i + m
			if t < self.n and self.bit[t] < x:
				i = t
				x -= self.bit[i]
			m //= 2
		return i + 1

import sys
input = sys.stdin.buffer.readline
from operator import itemgetter as get
def main():
	n, q = list(map(int, input().split()))
	event = []
	Xs = []
	for _ in range(n):
		s, t, x = list(map(int, input().split()))
		event.append((-2, s - x, x))
		event.append((-1, t - x, x))
		Xs.append(x)
	Xs.sort()
	for _ in range(q):
		d = int(eval(input()))
		event.append((0, d, None))
	event.sort(key=get(1))
	x_to_i = {x: i for i, x in enumerate(Xs)}
	bit = BIT(n)
	any = 0
	ans = []
	for flg, time, x in event:
		if flg == -2:
			bit.add(x_to_i[x], 1)
			any += 1
		elif flg == -1:
			bit.add(x_to_i[x], -1)
			any -= 1
		else:
			if not any:
				ans.append(-1)
			else:
				ans.append(Xs[bit.bisect(1)])
	print(("\n".join(map(str, ans))))

if __name__ == '__main__':
	main()

# Optimized solution
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter as get
from heapq import *


def main():
	n, q = list(map(int, input().split()))
	event = []
	Xs = []
	for _ in range(n):
		s, t, x = list(map(int, input().split()))
		event.append((-2, s - x, x))
		event.append((-1, t - x, x))
		Xs.append(x)
	for _ in range(q):
		d = int(eval(input()))
		event.append((0, d, None))
	event.sort(key=get(1))
	active = {x: 0 for x in Xs}
	candidate = []
	ans = []
	for flg, time, x in event:
		if flg == -2:
			active[x] = 1
			heappush(candidate, x)
		elif flg == -1:
			active[x] = 0
		else:
			res = -1
			while candidate:
				c = heappop(candidate)
				if active[c]:
					heappush(candidate, c)
					res = c
					break
			ans.append(res)
	print(("\n".join(map(str, ans))))


if __name__ == '__main__':
	main()
# Original solution
from heapq import heappush, heappop
n, q = list(map(int, input().split()))
events = []
for i in range(n):
    s, t, i = list(map(int, input().split()))
    if t >= i:
        events.append([t - i, 0, i])
        events.append([s - i, 1, i])
for i in range(q):
    d = int(eval(input()))
    events.append([d, 2, i])
events.sort()
heap = []
working = set()
distance = [-1] * q
for t, kind, i in events:
    if kind == 0:
        working.remove(i)
    elif kind == 1:
        working.add(i)
        heappush(heap, i)
    elif working:
        while not heap[0] in working:
            heappop(heap)
        distance[i] = heap[0]
for d in distance:
    print(d)

# Optimized solution
from heapq import heappush, heappop


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

for i in range(n):
    s, t, x = list(map(int, input().split()))
    if t >= x:
        events.append([t - x, 0, x])
        events.append([s - x, 1, x])
for i in range(q):
    d = int(eval(input()))
    events.append([d, 2, i])
events.sort()

dist = [-1] * q
walker = []
working = set()
heap = []
for t, kind, x in events:
    if kind == 0:
        working.remove(x)
    elif kind == 1:
        working.add(x)
        heappush(heap, x)
    elif working:
        while not heap[0] in working:
            heappop(heap)
        dist[x] = heap[0]

for d in dist:
    print(d)
# Original solution
from heapq import heappush, heappop


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

for i in range(n):
    s, t, x = list(map(int, input().split()))
    if t >= x:
        events.append([t - x, 0, x])
        events.append([s - x, 1, x])
for i in range(q):
    d = int(eval(input()))
    events.append([d, 2, i])
events.sort()

dist = [-1] * q
walker = []
working = set()
heap = []
for t, kind, x in events:
    if kind == 0:
        working.remove(x)
    elif kind == 1:
        working.add(x)
        heappush(heap, x)
    elif working:
        while not heap[0] in working:
            heappop(heap)
        dist[x] = heap[0]

for d in dist:
    print(d)

# Optimized solution
from heapq import heappush, heappop


n, q = map(int, input().split())
events = []

for i in range(n):
    s, t, x = map(int, input().split())
    if t >= x:
        events.append([t - x, 0, x])
        events.append([s - x, 1, x])
for i in range(q):
    d = int(input())
    events.append([d, 2, i])
events.sort()

dist = [-1] * q
walker = []
working = set()
heap = []
for t, kind, x in events:
    if kind == 0:
        working.remove(x)
    elif kind == 1:
        working.add(x)
        heappush(heap, x)
    elif working:
        while not heap[0] in working:
            heappop(heap)
        dist[x] = heap[0]

print(*dist, sep="\n")
# Original solution
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
import bisect

N,Q = list(map(int,input().split()))
# STX = [list(map(int,input().split())) for _ in range (N)]
STX = []
vals = set()
for _ in range(N):
    s,t,x = list(map(int,input().split()))
    STX.append([max(0,s-x), max(0,t-x), x])
    vals.add(max(0,s-x))
    vals.add(max(0,t-x))
D = [int(eval(input())) for _ in range(Q)]
for d in D:
    vals.add(d)
vals = list(vals)
vals.sort()
L = len(vals)
mapping = [-1]*(L+1)
imos = [[] for _ in range(L+1)]
STX.sort(key=lambda x:x[2])
priority = 0 
for s,t,x in STX:
    s1 = bisect.bisect_left(vals, s)
    t1 = bisect.bisect_left(vals, t)
    imos[s1].append([1, priority, x])
    imos[t1].append([0, priority, x])
    priority += 1

import heapq
cur = -1
cur_priority = 10**9
que = [[cur_priority, cur]]
valid_priority = [True]*(N+1)
for i in range(L+1):
    for f,p,x in  imos[i]:
        if f:
            heapq.heappush(que, [p, x])
        else:
            valid_priority[p] = False
    idx = 0
    while que[idx][0]!=10**9 and valid_priority[que[idx][0]]==False:
        heapq.heappop(que)
    mapping[i] = que[0][1]



        
for d in D:
    d1 = bisect.bisect_left(vals, d)
    print((mapping[d1]))



# Optimized solution
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
import bisect

N,Q = list(map(int,input().split()))
# STX = [list(map(int,input().split())) for _ in range (N)]
STX = []
vals = set()
for _ in range(N):
    s,t,x = list(map(int,input().split()))
    STX.append([max(0,s-x), max(0,t-x), x])
    vals.add(max(0,s-x))
    vals.add(max(0,t-x))
D = [int(eval(input())) for _ in range(Q)]
for d in D:
    vals.add(d)
vals = list(vals)
vals.sort()
L = len(vals)
mapping = [-1]*(L+1)
imos = [[] for _ in range(L+1)]
STX.sort(key=lambda x:x[2])
priority = 0 
for s,t,x in STX:
    s1 = bisect.bisect_left(vals, s)
    t1 = bisect.bisect_left(vals, t)
    imos[s1].append([1, priority, x])
    imos[t1].append([0, priority, x])
    priority += 1

import heapq
cur = -1
cur_priority = 10**9
que = [[cur_priority, cur]]
valid_priority = [True]*(N+1)
for i in range(L+1):
    for f,p,x in  imos[i]:
        if f:
            heapq.heappush(que, [p, x])
        else:
            valid_priority[p] = False
    
    while que[0][1]!=-1 and valid_priority[que[0][0]]==False:
        heapq.heappop(que)
    mapping[i] = que[0][1]

for d in D:
    d1 = bisect.bisect_left(vals, d)
    print((mapping[d1]))
# Original solution
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
import bisect

N,Q = list(map(int,input().split()))
# STX = [list(map(int,input().split())) for _ in range (N)]
STX = []
vals = set()
for _ in range(N):
    s,t,x = list(map(int,input().split()))
    STX.append((max(0,s-x), max(0,t-x), x))
    vals.add(max(0,s-x))
    vals.add(max(0,t-x))
D = [int(eval(input())) for _ in range(Q)]
for d in D:
    vals.add(d)
vals = list(vals)
vals.sort()
L = len(vals)
mapping = [-1]*(L+10)
STX.sort(key=lambda x:x[2])
for s,t,x in STX:
    s1 = bisect.bisect_left(vals, s)
    t1 = bisect.bisect_left(vals, t)
    for i in range(s1, t1):
        if mapping[i]==-1:
            mapping[i] = x
    
for d in D:
    d1 = bisect.bisect_left(vals, d)
    print((mapping[d1]))



# Optimized solution
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
import bisect

N,Q = list(map(int,input().split()))
# STX = [list(map(int,input().split())) for _ in range (N)]
STX = []
vals = set()
for _ in range(N):
    s,t,x = list(map(int,input().split()))
    STX.append((max(0,s-x), max(0,t-x), x))
    vals.add(max(0,s-x))
    vals.add(max(0,t-x))
D = [int(eval(input())) for _ in range(Q)]
for d in D:
    vals.add(d)
vals = list(vals)
vals.sort()
L = len(vals)
mapping = [-1]*(L+1)
imos = [[] for _ in range(L+1)]
STX.sort(key=lambda x:x[2])
priority = 0 
for s,t,x in STX:
    s1 = bisect.bisect_left(vals, s)
    t1 = bisect.bisect_left(vals, t)
    imos[s1].append([1, priority, x])
    imos[t1].append([0, priority, x])
    priority += 1

import heapq
cur = -1
cur_priority = 10**9
que = [(cur_priority, cur)]
valid_priority = [True]*(N+1)
for i in range(L+1):
    for f,p,x in  imos[i]:
        if f:
            heapq.heappush(que, (p, x))
        else:
            valid_priority[p] = False
    
    while que[0][1]!=-1 and valid_priority[que[0][0]]==False:
        heapq.heappop(que)
    mapping[i] = que[0][1]

for d in D:
    d1 = bisect.bisect_left(vals, d)
    print((mapping[d1]))
# Original solution
import sys
import bisect

input = sys.stdin.readline

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

STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])

D = [int(eval(input())) for _ in range(Q)]
ans = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    
    for i in range(left, right):
        if ans[i] == -1:
            ans[i] = x

for a in ans:
    print(a)

# Optimized solution
import sys
import bisect

input = sys.stdin.readline

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

STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])

D = [int(eval(input())) for _ in range(Q)]
ans = [-1] * Q
index = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    now = left
    while now < right:
        if index[now] == -1:  # まだansが更新されていない場合
            ans[now] = x
            index[now] = right
            now += 1
        else:
            now = index[now]
            

for a in ans:
    print(a)
# Original solution
from operator import itemgetter


def main():
    n, q = list(map(int, input().split()))
    stops = []
    for _ in range(n):
        s, t, x = list(map(int, input().split()))
        stops.append((s, t, x))
    delay = []
    for i in range(q):
        delay.append([int(eval(input())), False, -1])

    stops = sorted(stops, key=itemgetter(2))

    for s, t, x in stops:
        for idx, item in enumerate(delay):
            d, stopped, score = item
            if not stopped:
                time_at_x = x + d
                if s - 0.5 < time_at_x < t - 0.5:
                    delay[idx][2] = x
                    delay[idx][1] = True

    for item in delay:
        print((item[2]))


main()

# Optimized solution
from operator import itemgetter
from bisect import bisect_left


def main():
    n, q = list(map(int, input().split()))
    stops = []
    for _ in range(n):
        s, t, x = list(map(int, input().split()))
        stops.append((s, t, x))
    delay = []
    for i in range(q):
        delay.append(int(eval(input())))

    stops = sorted(stops, key=itemgetter(2))
    delay = sorted(delay)

    result = [-1] * q
    skips = [-1] * q

    for s, t, x in stops:
        sx = bisect_left(delay, s - x)
        tx = bisect_left(delay, t - x)
        while sx < tx:
            if skips[sx] == -1:
                result[sx] = x
                skips[sx] = tx
                sx += 1
            else:
                sx = skips[sx]

    for r in result:
        print(r)


main()
# Original solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    # print("#F")
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    # print(S,number)
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))




# Optimized solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))
# Original solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))




# Optimized solution
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
# inf = float('inf') ;mod = 10**9+7
# mans = inf ;ans = 0 ;count = 0 ;pro = 1
from heapq import heappush,heappop

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))
# Original solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
# inf = float('inf') ;mod = 10**9+7
# mans = inf ;ans = 0 ;count = 0 ;pro = 1
from heapq import heappush,heappop

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))




# Optimized solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))
# Original solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline()
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=map(int,input().split())
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(input()) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
ans = []
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      ans.append(-1)
    else:
      ans.append(hq[0])
print(*ans,sep="\n")




# Optimized solution
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,q=list(map(int,input().split()))
STX=[tuple(map(int,input().split())) for i in range(n)]
D=[int(eval(input())) for i in range(q)]
event=[]
for si,ti,xi in STX:
  event.append((si-xi,0,xi))
  event.append((ti-xi,-1,xi))
for di in D:
  event.append((di,1,di))
event.sort()
hq=[]; S=set()
for time, query, number in event:
  if query == 0:
    heapq.heappush(hq,number)
    S.add(number)
  elif query == -1:
    S.remove(number)
  else:
    while hq and hq[0] not in S:
      heapq.heappop(hq)
    if not hq:
      print((-1))
    else:
      print((hq[0]))
# Original solution
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin
from heapq import heappush, heappop



readl = stdin.readline

## input
N,Q = list(map(int, readl().rstrip().split()))
STX = [list(map(int, readl().rstrip().split())) for _ in range(N)]
Dn = [None for _ in range(Q+1)]
for i in range(Q):
  Dn[i] = int(readl().rstrip())
Dn[Q] = 10**10
Rn = []


## solve
for s,t,x in sorted(STX,key=lambda x:x[2]):
  l = r = bisect_left(Dn,s-x)
  t -= x
  while Dn[r] < t:
    Rn.append([Dn[r],x])
    r += 1
  del Dn[l:r]

for d in Dn[:-1]:
  Rn.append([d,-1])
Rn.sort()


## output
for i in range(Q):
  print((Rn[i][1]))

# Optimized solution
import sys
from bisect import bisect_left



N,Q = list(map(int, input().split()))
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = list(map(int, line.split()))
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

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