import sys
input = sys.stdin.readline
N, Q = [int(_) for _ in input().split()]
STX = [[int(_) for _ in input().split()] for _ in range(N)]
D = [int(input()) for _ in range(Q)]
events = []
for stx in STX:
    s, t, x = stx
    events += [[s - x, 1, x], [t - x, 0, x]]
for i in range(Q):
    events += [[D[i], 2, i]]
events.sort()
block = set()
ans = [-1] * Q
m = float('inf')
for e in events:
    if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m
print(*ans, sep='\n') import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline int(_) for _ in input().split() for _ in input().split() _ input().split() ().split () input split for _ in input().split() int(_) int _ N, Q = [int(_) for _ in input().split()] N [int(_) for _ in input().split()] Q [int(_) for _ in input().split()] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [int(_) for _ in input().split()] STX = [[int(_) for _ in input().split()] for _ in range(N)] STX [[int(_) for _ in input().split()] for _ in range(N)] int(input()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) int(input()) int input() input D = [int(input()) for _ in range(Q)] D [int(input()) for _ in range(Q)] events = [] events [] for stx in STX:
    s, t, x = stx
    events += [[s - x, 1, x], [t - x, 0, x]] stx STX s, t, x = stx s stx t x events += [[s - x, 1, x], [t - x, 0, x]] events [[s - x, 1, x], [t - x, 0, x]] [s - x, 1, x] s - x s x 1 x [t - x, 0, x] t - x t x 0 x for i in range(Q):
    events += [[D[i], 2, i]] i range(Q) range Q events += [[D[i], 2, i]] events [[D[i], 2, i]] [D[i], 2, i] D[i] D i 2 i events.sort() events.sort events sort block = set() block set() set ans = [-1] * Q ans [-1] * Q [-1] -1 Q m = float('inf') m float('inf') float 'inf' for e in events:
    if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m e events if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m e[1] == 0 e[1] e 1 0 block.remove(e[2]) block.remove block remove e[2] e 2 if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
     m == e[2] m e[2] e 2 if block:
                m = min(block)
            else:
                m = float('inf')
     block m = min(block) m min(block) min block m = float('inf') m float('inf') float 'inf' elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
     e[1] == 1 e[1] e 1 1 block.add(e[2]) block.add block add e[2] e 2 m = min(m, e[2]) m min(m, e[2]) min m e[2] e 2 if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m block if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m m == float('inf') m float('inf') float 'inf' ans[e[2]] = -1 ans[e[2]] ans e[2] e 2 -1 ans[e[2]] = m ans[e[2]] ans e[2] e 2 m print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' s, t, x = stx stx s STX = [[int(_) for _ in input().split()] for _ in range(N)] [[int(_) for _ in input().split()] for _ in range(N)] STX m = min(m, e[2]) min(m, e[2]) m t, x = stx stx t events = [] [] events events += [[D[i], 2, i]] [[D[i], 2, i]] events block = set() set() block events += [[s - x, 1, x], [t - x, 0, x]] [[s - x, 1, x], [t - x, 0, x]] events x = stx stx x m = min(block) min(block) m m = float('inf') float('inf') m Q = [int(_) for _ in input().split()] [int(_) for _ in input().split()] Q ans = [-1] * Q [-1] * Q ans D = [int(input()) for _ in range(Q)] [int(input()) for _ in range(Q)] D m = float('inf') float('inf') m input = sys.stdin.readline sys.stdin.readline input N, Q = [int(_) for _ in input().split()] [int(_) for _ in input().split()] N
import sys
input = sys.stdin.readline
N, Q = [int(_) for _ in input().split()]
STX = [[int(_) for _ in input().split()] for _ in range(N)]
D = [int(input()) for _ in range(Q)]
events = []
for stx in STX:
    s, t, x = stx
    events += [[s - x, 1, x], [t - x, 0, x]]
for i in range(Q):
    events += [[D[i], 2, i]]
events.sort()
block = set()
ans = [-1] * Q
m = float('inf')
for e in events:
    if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m
print(*ans, sep='\n')
