import sys
from operator import itemgetter
from heapq import heapify, heappush, heappop

read = sys.stdin.read

N, Q, *STXD = map(int, read().split())
STX = STXD[:3 * N]
queue = []

for i, (S, T, X) in enumerate(zip(*[iter(STX)] * 3), 1):
    queue.append((S - X - 0.5, X, i))
    queue.append((T - X - 0.5, -X, i))

for D in STXD[3 * N:]:
    queue.append((D, 0, 0))

queue.sort(key=itemgetter(0), reverse=True)
heap = []
heapify(heap)
stop, construction = -1, 0
not_available = set()
while queue:
    _, x, n = queue.pop()
    if x == 0:
        print(stop)
    elif x < 0:
        not_available.add(n)
        if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
    else:
        if stop != -1:
            if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
        else:
            stop, construction = x, n import sys sys from operator import itemgetter from heapq import heapify, heappush, heappop read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read N, Q, *STXD = map(int, read().split()) N map(int, read().split()) map int read().split() ().split () read split Q *STXD STXD STX = STXD[:3 * N] STX STXD[:3 * N] STXD :3 * N 3 * N 3 N queue = [] queue [] for i, (S, T, X) in enumerate(zip(*[iter(STX)] * 3), 1):
    queue.append((S - X - 0.5, X, i))
    queue.append((T - X - 0.5, -X, i)) i (S, T, X) S T X enumerate(zip(*[iter(STX)] * 3), 1) enumerate zip(*[iter(STX)] * 3) zip *[iter(STX)] * 3 [iter(STX)] * 3 [iter(STX)] iter(STX) iter STX 3 1 queue.append((S - X - 0.5, X, i)) queue.append queue append (S - X - 0.5, X, i) S - X - 0.5 S - X S X 0.5 X i queue.append((T - X - 0.5, -X, i)) queue.append queue append (T - X - 0.5, -X, i) T - X - 0.5 T - X T X 0.5 -X X i for D in STXD[3 * N:]:
    queue.append((D, 0, 0)) D STXD[3 * N:] STXD 3 * N: 3 * N 3 N queue.append((D, 0, 0)) queue.append queue append (D, 0, 0) D 0 0 queue.sort(key=itemgetter(0), reverse=True) queue.sort queue sort key=itemgetter(0) key itemgetter(0) itemgetter 0 reverse=True reverse True heap = [] heap [] heapify(heap) heapify heap stop, construction = -1, 0 stop -1 construction 0 not_available = set() not_available set() set while queue:
    _, x, n = queue.pop()
    if x == 0:
        print(stop)
    elif x < 0:
        not_available.add(n)
        if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
    else:
        if stop != -1:
            if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
        else:
            stop, construction = x, n queue _, x, n = queue.pop() _ queue.pop() queue.pop queue pop x n if x == 0:
        print(stop)
    elif x < 0:
        not_available.add(n)
        if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
    else:
        if stop != -1:
            if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
        else:
            stop, construction = x, n x == 0 x 0 print(stop) print stop elif x < 0:
        not_available.add(n)
        if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
     x < 0 x 0 not_available.add(n) not_available.add not_available add n if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
     n == construction n construction while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
     heap stop, construction = heappop(heap) stop heappop(heap) heappop heap construction if construction not in not_available:
                    break
             construction not in not_available construction not_available break stop, construction = -1, 0 stop -1 construction 0 if stop != -1:
            if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
        else:
            stop, construction = x, n stop != -1 stop -1 if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
         stop <= x stop x heappush(heap, (x, n)) heappush heap (x, n) x n heappush(heap, (stop, construction)) heappush heap (stop, construction) stop construction stop, construction = x, n stop x construction n stop, construction = x, n stop x construction n stop, construction = x, n x stop construction = x, n n construction construction = heappop(heap) heappop(heap) construction n = queue.pop() queue.pop() n N, Q, *STXD = map(int, read().split()) map(int, read().split()) N not_available = set() set() not_available STX = STXD[:3 * N] STXD[:3 * N] STX construction = -1, 0 0 construction read = sys.stdin.read sys.stdin.read read queue = [] [] queue stop, construction = -1, 0 -1 stop x, n = queue.pop() queue.pop() x heap = [] [] heap stop, construction = heappop(heap) heappop(heap) stop Q, *STXD = map(int, read().split()) map(int, read().split()) Q stop, construction = x, n x stop stop, construction = -1, 0 -1 stop _, x, n = queue.pop() queue.pop() _ construction = x, n n construction construction = -1, 0 0 construction
import sys
from operator import itemgetter
from heapq import heapify, heappush, heappop

read = sys.stdin.read

N, Q, *STXD = map(int, read().split())
STX = STXD[:3 * N]
queue = []

for i, (S, T, X) in enumerate(zip(*[iter(STX)] * 3), 1):
    queue.append((S - X - 0.5, X, i))
    queue.append((T - X - 0.5, -X, i))

for D in STXD[3 * N:]:
    queue.append((D, 0, 0))

queue.sort(key=itemgetter(0), reverse=True)
heap = []
heapify(heap)
stop, construction = -1, 0
not_available = set()
while queue:
    _, x, n = queue.pop()
    if x == 0:
        print(stop)
    elif x < 0:
        not_available.add(n)
        if n == construction:
            while heap:
                stop, construction = heappop(heap)
                if construction not in not_available:
                    break
            else:
                stop, construction = -1, 0
    else:
        if stop != -1:
            if stop <= x:
                heappush(heap, (x, n))
            else:
                heappush(heap, (stop, construction))
                stop, construction = x, n
        else:
            stop, construction = x, n
