import sys
from heapq import heappush, heappop

n, q = map(int, sys.stdin.readline().split())
stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
*d, = map(int, sys.stdin.read().split())

def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n') import sys sys from heapq import heappush, heappop n, q = map(int, sys.stdin.readline().split()) n map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split q tuple(map(int, sys.stdin.readline().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(map(int, sys.stdin.readline().split())) tuple map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)] stx [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)] *d, = map(int, sys.stdin.read().split()) *d d map(int, sys.stdin.read().split()) map int sys.stdin.read().split() sys.stdin.read().split sys.stdin.read() sys.stdin.read sys.stdin sys stdin read split def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res main queue = [] queue [] for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
     s t x stx queue.append((s-x, 1, x)) queue.append queue append (s-x, 1, x) s-x s x 1 x queue.append((t-x, 0, x)) queue.append queue append (t-x, 0, x) t-x t x 0 x for i in range(q):
        queue.append((d[i], 2, i))
    
     i range(q) range q queue.append((d[i], 2, i)) queue.append queue append (d[i], 2, i) d[i] d i 2 i queue.sort() queue.sort queue sort res = [None] * q res [None] * q [None] None q hq = [] hq [] running = set() running set() set for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
     t f x queue if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
     f == 1 f 1 heappush(hq, x) heappush hq x running.add(x) running.add running add x elif f == 0:
            running -= set([x])
         f == 0 f 0 running -= set([x]) running set([x]) set [x] x elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
     f == 2 f 2 i = x i x while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
     hq if not hq[0] in running:
                    heappop(hq)
                    continue
                 not hq[0] in running hq[0] in running hq[0] hq 0 running heappop(hq) heappop hq continue res[i] = hq[0] res[i] res i hq[0] hq 0 break res[i] = -1 res[i] res i -1 return res res if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n') __name__ == '__main__' __name__ '__main__' ans = main() ans main() main print(*ans, sep='\n') print *ans ans sep='\n' sep '\n' stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)] [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)] stx n, q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) n def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res main q = map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) q ans = main() main() ans
import sys
from heapq import heappush, heappop

n, q = map(int, sys.stdin.readline().split())
stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
*d, = map(int, sys.stdin.read().split())

def main():
    queue = []
    for s, t, x in stx:
        queue.append((s-x, 1, x))
        queue.append((t-x, 0, x))
    
    for i in range(q):
        queue.append((d[i], 2, i))
    
    queue.sort()

    res = [None] * q
    hq = []
    running = set()
    
    for t, f, x in queue:
        if f == 1:
            heappush(hq, x)
            running.add(x)
        elif f == 0:
            running -= set([x])
        elif f == 2:
            i = x
            while hq:
                if not hq[0] in running:
                    heappop(hq)
                    continue
                res[i] = hq[0]
                break
            else:
                res[i] = -1
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')