
from heapq import *
def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break

if __name__ == '__main__':
    main() from heapq import * def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break main import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, Q = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split Q X = [] X [] for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
     _ range(N) range N s, t, x = map(int, input().split()) s map(int, input().split()) map int input().split() ().split () input split t x X.append((2*s-2*x-1, 0, x)) X.append X append (2*s-2*x-1, 0, x) 2*s-2*x-1 2*s-2*x 2*s 2 s 2*x 2 x 1 0 x X.append((2*t-2*x-1, 1, x)) X.append X append (2*t-2*x-1, 1, x) 2*t-2*x-1 2*t-2*x 2*t 2 t 2*x 2 x 1 1 x inf = 10**18 inf 10**18 10 18 X.append((-inf, 0, inf)) X.append X append (-inf, 0, inf) -inf inf 0 inf X.append((inf, 1, inf)) X.append X append (inf, 1, inf) inf 1 inf X.sort(key=lambda x: x[0]) X.sort X sort key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x j = 0 j 0 ll = [] ll [] vs = set() vs set() set d = dict() d dict() dict for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break _ range(Q) range Q q = int(input()) q int(input()) int input() input while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
         1 u, f, x = X[j] u X[j] X j f x if u > 2*q:
                break
             u > 2*q u 2*q 2 q break if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
             f if x not in d:
                    d[x] = 0
                 x not in d x d d[x] = 0 d[x] d x 0 d[x] += 1 d[x] d x 1 heappush(ll, x) heappush ll x j += 1 j 1 while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break 1 x = heappop(ll) x heappop(ll) heappop ll if x in d and d[x] > 0:
                d[x] -= 1
                continue
             x in d and d[x] > 0 x in d x d d[x] > 0 d[x] d x 0 d[x] -= 1 d[x] d x 1 continue heappush(ll, x) heappush ll x if x == inf:
                print(-1)
            else:
                print(x)
             x == inf x inf print(-1) print -1 print(x) print x break if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break main

from heapq import *
def main():
    import sys;input=sys.stdin.readline
    N, Q = map(int, input().split())
    X = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        X.append((2*s-2*x-1, 0, x))
        X.append((2*t-2*x-1, 1, x))
    inf = 10**18
    X.append((-inf, 0, inf))
    X.append((inf, 1, inf))
    X.sort(key=lambda x: x[0])

    j = 0
    ll = []
    vs = set()
    d = dict()
    for _ in range(Q):
        q = int(input())
        while 1:
            u, f, x = X[j]
            if u > 2*q:
                break
            if f:
                if x not in d:
                    d[x] = 0
                d[x] += 1
            else:
                heappush(ll, x)
            j += 1
        while 1:
            x = heappop(ll)
            if x in d and d[x] > 0:
                d[x] -= 1
                continue
            heappush(ll, x)
            if x == inf:
                print(-1)
            else:
                print(x)
            break

if __name__ == '__main__':
    main()
