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))))

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()

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))))

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()

-input = sys.stdin.readline -from heapq import heappop, heappush +input = sys.stdin.buffer.readline +import heapq -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)))) + +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()