from heapq import heappop, heappush

import sys
input = sys.stdin.buffer.readline


def main():

    n, q = map(int, input().split())
    stx = [map(int, input().split()) for _ in range(n)]
    ds = [int(input()) for _ in range(q)]
    INF = 10 ** 9 + 1
    CHECK = 2
    START = 1
    END = 0
    NULL = 0

    tfdi = []
    for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

    for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
    tfdi.append((INF, START, INF, -1))
    tfdi.sort()

    hp = [(INF, -1)]
    ans = []
    passed = set()
    for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

    print(*ans, sep="\n")


if __name__ == "__main__":
    main() from heapq import heappop, heappush import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def main():

    n, q = map(int, input().split())
    stx = [map(int, input().split()) for _ in range(n)]
    ds = [int(input()) for _ in range(q)]
    INF = 10 ** 9 + 1
    CHECK = 2
    START = 1
    END = 0
    NULL = 0

    tfdi = []
    for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

    for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
    tfdi.append((INF, START, INF, -1))
    tfdi.sort()

    hp = [(INF, -1)]
    ans = []
    passed = set()
    for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

    print(*ans, sep="\n") main n, q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q map(int, input().split()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) map(int, input().split()) map int input().split() ().split () input split stx = [map(int, input().split()) for _ in range(n)] stx [map(int, 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 ds = [int(input()) for _ in range(q)] ds [int(input()) for _ in range(q)] INF = 10 ** 9 + 1 INF 10 ** 9 + 1 10 ** 9 10 9 1 CHECK = 2 CHECK 2 START = 1 START 1 END = 0 END 0 NULL = 0 NULL 0 tfdi = [] tfdi [] for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

     i (s, t, x) s t x enumerate(stx) enumerate stx t_start = max(0, s - x) t_start max(0, s - x) max 0 s - x s x t_end = max(0, t - x) t_end max(0, t - x) max 0 t - x t x tfdi.append((t_start, START, x, i)) tfdi.append tfdi append (t_start, START, x, i) t_start START x i tfdi.append((t_end, END, x, i)) tfdi.append tfdi append (t_end, END, x, i) t_end END x i for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
     d ds tfdi.append((d, CHECK, NULL, NULL)) tfdi.append tfdi append (d, CHECK, NULL, NULL) d CHECK NULL NULL tfdi.append((INF, START, INF, -1)) tfdi.append tfdi append (INF, START, INF, -1) INF START INF -1 tfdi.sort() tfdi.sort tfdi sort hp = [(INF, -1)] hp [(INF, -1)] (INF, -1) INF -1 ans = [] ans [] passed = set() passed set() set for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

     t f d i tfdi if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

     f == CHECK f CHECK while hp[0][1] in passed:
                heappop(hp)
             hp[0][1] in passed hp[0][1] [0] hp 0 1 passed heappop(hp) heappop hp if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
             hp[0][0] == INF hp[0][0] [0] hp 0 0 INF tmp = -1 tmp -1 tmp = hp[0][0] tmp hp[0][0] [0] hp 0 0 ans.append(tmp) ans.append ans append tmp elif f == START:
            heappush(hp, (d, i))
         f == START f START heappush(hp, (d, i)) heappush hp (d, i) d i passed.add(i) passed.add passed add i print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.buffer.readline sys.stdin.buffer.readline input def main():

    n, q = map(int, input().split())
    stx = [map(int, input().split()) for _ in range(n)]
    ds = [int(input()) for _ in range(q)]
    INF = 10 ** 9 + 1
    CHECK = 2
    START = 1
    END = 0
    NULL = 0

    tfdi = []
    for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

    for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
    tfdi.append((INF, START, INF, -1))
    tfdi.sort()

    hp = [(INF, -1)]
    ans = []
    passed = set()
    for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

    print(*ans, sep="\n") def main():

    n, q = map(int, input().split())
    stx = [map(int, input().split()) for _ in range(n)]
    ds = [int(input()) for _ in range(q)]
    INF = 10 ** 9 + 1
    CHECK = 2
    START = 1
    END = 0
    NULL = 0

    tfdi = []
    for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

    for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
    tfdi.append((INF, START, INF, -1))
    tfdi.sort()

    hp = [(INF, -1)]
    ans = []
    passed = set()
    for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

    print(*ans, sep="\n") main
from heapq import heappop, heappush

import sys
input = sys.stdin.buffer.readline


def main():

    n, q = map(int, input().split())
    stx = [map(int, input().split()) for _ in range(n)]
    ds = [int(input()) for _ in range(q)]
    INF = 10 ** 9 + 1
    CHECK = 2
    START = 1
    END = 0
    NULL = 0

    tfdi = []
    for i, (s, t, x) in enumerate(stx):
        t_start = max(0, s - x)
        t_end = max(0, t - x)

        tfdi.append((t_start, START, x, i))
        tfdi.append((t_end, END, x, i))

    for d in ds:
        tfdi.append((d, CHECK, NULL, NULL))
    tfdi.append((INF, START, INF, -1))
    tfdi.sort()

    hp = [(INF, -1)]
    ans = []
    passed = set()
    for t, f, d, i in tfdi:
        if f == CHECK:
            while hp[0][1] in passed:
                heappop(hp)
            if hp[0][0] == INF:
                tmp = -1
            else:
                tmp = hp[0][0]
            ans.append(tmp)

        elif f == START:
            heappush(hp, (d, i))
        else:
            passed.add(i)

    print(*ans, sep="\n")


if __name__ == "__main__":
    main()
