# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

import sys
input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))

class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
    def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
    def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
    def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
    def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1

class DammySet:

    def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

    def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


    def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


    def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


    def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals

N, M = inpl()
Q = sorted([inpl() for _ in range(N)], key=itemgetter(2))
D = [int(input()) for _ in range(M)]
rD = {v:i for i, v in enumerate(D)}
ans = [-1]*(M)
 
dmap = DammySet(D)
 
for s, t, x in Q:
    val = dmap.pop_vals(s-x, t-1-x)
    for v in val:
        ans[rD[v]] = x
 
print(*ans, sep="\n") from bisect import bisect, bisect_left from collections import Counter from functools import reduce from itertools import accumulate from operator import itemgetter, xor import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def inpl(): return list(map(int, input().split())) inpl class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
    def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
    def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
    def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
    def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1 BIT def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
     __init__ self.size = 2 ** (int.bit_length(N+1)) self.size self size 2 ** (int.bit_length(N+1)) 2 int.bit_length(N+1) int.bit_length int bit_length N+1 N 1 self.node = [0]*(self.size + 1) self.node self node [0]*(self.size + 1) [0] 0 self.size + 1 self.size self size 1 self self N N def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
     initialize if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
         len(S) < self.size + 1 len(S) len S self.size + 1 self.size self size 1 S += [S[-1]] * (self.size+1 - len(S)) S [S[-1]] * (self.size+1 - len(S)) [S[-1]] S[-1] S -1 self.size+1 - len(S) self.size+1 self.size self size 1 len(S) len S for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
     i range(1, self.size+1) range 1 self.size+1 self.size self size 1 self.node[i] = S[i] - S[i - (i&-i)] self.node[i] self.node self node i S[i] - S[i - (i&-i)] S[i] S i S[i - (i&-i)] S i - (i&-i) i i&-i i -i i self self S S def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
     sum res = 0 res 0 while i:
            res += self.node[i]
            i -= (i & -(i))
         i res += self.node[i] res self.node[i] self.node self node i i -= (i & -(i)) i i & -(i) i -(i) i return res res self self i i def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
     add if i == 0:
            return
         i == 0 i 0 return while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
     i <= self.size i self.size self size self.node[i] += x self.node[i] self.node self node i x i += (i & -(i)) i i & -(i) i -(i) i self self i i x x def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
     bisect_left res = 0 res 0 tmp = 0 tmp 0 b = 2**(int.bit_length(self.size)-2) b 2**(int.bit_length(self.size)-2) 2 int.bit_length(self.size)-2 int.bit_length(self.size) int.bit_length int bit_length self.size self size 2 while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
         b if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
             tmp + self.node[res+b] < x tmp + self.node[res+b] tmp self.node[res+b] self.node self node res+b res b x res += b res b tmp += self.node[res] tmp self.node[res] self.node self node res b //= 2 b 2 return res + 1 res + 1 res 1 self self x x def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1 bisect res = 0 res 0 tmp = 0 tmp 0 b = 2**(int.bit_length(self.size)-2) b 2**(int.bit_length(self.size)-2) 2 int.bit_length(self.size)-2 int.bit_length(self.size) int.bit_length int bit_length self.size self size 2 while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
         b if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
             tmp + self.node[res+b] <= x tmp + self.node[res+b] tmp self.node[res+b] self.node self node res+b res b x res += b res b tmp += self.node[res] tmp self.node[res] self.node self node res b //= 2 b 2 return res + 1 res + 1 res 1 self self x x class DammySet:

    def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

    def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


    def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


    def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


    def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals DammySet def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

     __init__ if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

     not counter_is_unique_and_sorted counter_is_unique_and_sorted if type(counter) != Counter:
                counter = Counter(counter)

             type(counter) != Counter type(counter) type counter Counter counter = Counter(counter) counter Counter(counter) Counter counter self.bit = BIT(len(counter.keys())+3) self.bit self bit BIT(len(counter.keys())+3) BIT len(counter.keys())+3 len(counter.keys()) len counter.keys() counter.keys counter keys 3 self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF]) self.key self key sorted([-INF, -INF] + sorted(counter.keys()) + [INF]) sorted [-INF, -INF] + sorted(counter.keys()) + [INF] [-INF, -INF] + sorted(counter.keys()) [-INF, -INF] -INF INF -INF INF sorted(counter.keys()) sorted counter.keys() counter.keys counter keys [INF] INF counter[k] for k in self.key for k in self.key k self.key self key for k in self.key counter[k] counter k self.val = [counter[k] for k in self.key] self.val self val [counter[k] for k in self.key] S = list(accumulate(self.val)) S list(accumulate(self.val)) list accumulate(self.val) accumulate self.val self val self.bit.initialize(S) self.bit.initialize self.bit self bit initialize S self.bit = BIT(len(counter) + 3) self.bit self bit BIT(len(counter) + 3) BIT len(counter) + 3 len(counter) len counter 3 self.key = [-INF] * (len(counter) + 3) self.key self key [-INF] * (len(counter) + 3) [-INF] -INF INF len(counter) + 3 len(counter) len counter 3 self.val = [0] * (len(counter) + 3) self.val self val [0] * (len(counter) + 3) [0] 0 len(counter) + 3 len(counter) len counter 3 S = [0] * (len(counter) + 3) S [0] * (len(counter) + 3) [0] 0 len(counter) + 3 len(counter) len counter 3 for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
             i range(2, len(counter)+2) range 2 len(counter)+2 len(counter) len counter 2 self.key[i] = counter[i-2] self.key[i] self.key self key i counter[i-2] counter i-2 i 2 self.val[i] = 1 self.val[i] self.val self val i 1 S[i] = i-1 S[i] S i i-1 i 1 self.key[-1] = INF self.key[-1] self.key self key -1 INF S[-1] = len(counter) S[-1] S -1 len(counter) len counter self.bit.initialize(S) self.bit.initialize self.bit self bit initialize S self self counter counter INF=2**32 INF 2**32 2 32 counter_is_unique_and_sorted=True counter_is_unique_and_sorted True def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


     add ix = bisect_left(self.key, val) ix bisect_left(self.key, val) bisect_left self.key self key val assert self.key[ix] == val self.key[ix] == val self.key[ix] self.key self key ix val self.bit.add(ix, 1) self.bit.add self.bit self bit add ix 1 self self val val def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


     update for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


     k v Counter(vals).items() (vals).items (vals) Counter vals items ix = bisect_left(self.key, k) ix bisect_left(self.key, k) bisect_left self.key self key k if self.key[ix] != k:
                raise KeyError
             self.key[ix] != k self.key[ix] self.key self key ix k raise KeyError KeyError self.bit.add(ix, v) self.bit.add self.bit self bit add ix v self self vals vals def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


     remove for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


     k v Counter(vals).items() (vals).items (vals) Counter vals items ix = bisect_left(self.key, k) ix bisect_left(self.key, k) bisect_left self.key self key k if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
             self.key[ix] != k self.key[ix] self.key self key ix k raise KeyError KeyError assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0 self.bit.sum(ix) - self.bit.sum(ix-1) > 0 self.bit.sum(ix) - self.bit.sum(ix-1) self.bit.sum(ix) self.bit.sum self.bit self bit sum ix self.bit.sum(ix-1) self.bit.sum self.bit self bit sum ix-1 ix 1 0 self.bit.add(ix, -v) self.bit.add self.bit self bit add ix -v v self self vals vals def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals pop_vals assert l <= r l <= r l r rix = bisect(self.key, r) - 1 rix bisect(self.key, r) - 1 bisect(self.key, r) bisect self.key self key r 1 lix = bisect_left(self.key, l) - 1 lix bisect_left(self.key, l) - 1 bisect_left(self.key, l) bisect_left self.key self key l 1 rv = self.bit.sum(rix) rv self.bit.sum(rix) self.bit.sum self.bit self bit sum rix lv = self.bit.sum(lix) lv self.bit.sum(lix) self.bit.sum self.bit self bit sum lix delta = rv - lv delta rv - lv rv lv tv = lv+1 tv lv+1 lv 1 tix = lix*1 tix lix*1 lix 1 vix = 0 vix 0 rmvix = 0 rmvix 0 vals = [0]*delta vals [0]*delta [0] 0 delta rmvk = [0]*delta rmvk [0]*delta [0] 0 delta rmvv = [0]*delta rmvv [0]*delta [0] 0 delta while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

         delta OK = self.bit.bisect_left(tv) OK self.bit.bisect_left(tv) self.bit.bisect_left self.bit self bit bisect_left tv c = self.bit.sum(OK) c self.bit.sum(OK) self.bit.sum self.bit self bit sum OK d = c - tv + 1 d c - tv + 1 c - tv c tv 1 for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
             _ range(d) range d vals[vix] = self.key[OK] vals[vix] vals vix self.key[OK] self.key self key OK vix += 1 vix 1 rmvk[rmvix] = OK rmvk[rmvix] rmvk rmvix OK rmvv[rmvix] = d rmvv[rmvix] rmvv rmvix d rmvix += 1 rmvix 1 tv += d tv d tix = OK tix OK delta -= d delta d for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
         i range(rmvix) range rmvix self.bit.add(rmvk[i], -rmvv[i]) self.bit.add self.bit self bit add rmvk[i] rmvk i -rmvv[i] rmvv[i] rmvv i return vals vals self self l l r r N, M = inpl() N inpl() inpl M inpl() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) inpl() inpl Q = sorted([inpl() for _ in range(N)], key=itemgetter(2)) Q sorted([inpl() for _ in range(N)], key=itemgetter(2)) sorted [inpl() for _ in range(N)] key=itemgetter(2) key itemgetter(2) itemgetter 2 int(input()) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) int(input()) int input() input D = [int(input()) for _ in range(M)] D [int(input()) for _ in range(M)] v:i for i, v in enumerate(D) for i, v in enumerate(D) i v enumerate(D) enumerate D for i, v in enumerate(D) v i rD = {v:i for i, v in enumerate(D)} rD {v:i for i, v in enumerate(D)} ans = [-1]*(M) ans [-1]*(M) [-1] -1 M dmap = DammySet(D) dmap DammySet(D) DammySet D for s, t, x in Q:
    val = dmap.pop_vals(s-x, t-1-x)
    for v in val:
        ans[rD[v]] = x
  s t x Q val = dmap.pop_vals(s-x, t-1-x) val dmap.pop_vals(s-x, t-1-x) dmap.pop_vals dmap pop_vals s-x s x t-1-x t-1 t 1 x for v in val:
        ans[rD[v]] = x
  v val ans[rD[v]] = x ans[rD[v]] ans rD[v] rD v x print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" input = sys.stdin.readline sys.stdin.readline input dmap = DammySet(D) DammySet(D) dmap class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
    def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
    def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
    def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
    def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1 class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
    def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
    def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
    def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
    def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1 BIT M = inpl() inpl() M Q = sorted([inpl() for _ in range(N)], key=itemgetter(2)) sorted([inpl() for _ in range(N)], key=itemgetter(2)) Q val = dmap.pop_vals(s-x, t-1-x) dmap.pop_vals(s-x, t-1-x) val N, M = inpl() inpl() N def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl ans = [-1]*(M) [-1]*(M) ans class DammySet:

    def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

    def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


    def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


    def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


    def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals class DammySet:

    def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

    def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


    def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


    def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


    def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals DammySet rD = {v:i for i, v in enumerate(D)} {v:i for i, v in enumerate(D)} rD D = [int(input()) for _ in range(M)] [int(input()) for _ in range(M)] D
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

import sys
input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))

class BIT:
    def __init__(self, N):
        # Nは入れたい要素の個数
        self.size = 2 ** (int.bit_length(N+1))
        self.node = [0]*(self.size + 1)
 
    def initialize(self, S):
        # S[0] = 0にしておく
        # 1-indexed
        if len(S) < self.size + 1:
            S += [S[-1]] * (self.size+1 - len(S))
        for i in range(1, self.size+1):
            self.node[i] = S[i] - S[i - (i&-i)]
 
    def sum(self, i):
        res = 0
        while i:
            res += self.node[i]
            i -= (i & -(i))
        return res
 
    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.node[i] += x
            i += (i & -(i))
 
    def bisect_left(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] < x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1
 
    def bisect(self, x):
        res = 0
        tmp = 0
        b = 2**(int.bit_length(self.size)-2)
        while b:
            if tmp + self.node[res+b] <= x:
                res += b
                tmp += self.node[res]
            b //= 2
        return res + 1

class DammySet:

    def __init__(self, counter, INF=2**32, counter_is_unique_and_sorted=True):
        if not counter_is_unique_and_sorted:
            if type(counter) != Counter:
                counter = Counter(counter)

            self.bit = BIT(len(counter.keys())+3)
            self.key = sorted([-INF, -INF] + sorted(counter.keys()) + [INF])
            self.val = [counter[k] for k in self.key]
            S = list(accumulate(self.val))
            self.bit.initialize(S)

        else:
            self.bit = BIT(len(counter) + 3)
            self.key = [-INF] * (len(counter) + 3)
            self.val = [0] * (len(counter) + 3)
            S = [0] * (len(counter) + 3)
            for i in range(2, len(counter)+2):
                self.key[i] = counter[i-2]
                self.val[i] = 1
                S[i] = i-1
            self.key[-1] = INF
            S[-1] = len(counter)
            self.bit.initialize(S)

    def add(self, val):
        ix = bisect_left(self.key, val)
        assert self.key[ix] == val
        self.bit.add(ix, 1)


    def update(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            self.bit.add(ix, v)


    def remove(self, vals):
        for k, v in Counter(vals).items():
            ix = bisect_left(self.key, k)
            if self.key[ix] != k:
                raise KeyError
            
            # 空の値を削除しないかのチェック
            # 時間が厳しそうなときはコメントアウト
            assert self.bit.sum(ix) - self.bit.sum(ix-1) > 0

            self.bit.add(ix, -v)


    def pop_vals(self, l, r):
        assert l <= r

        rix = bisect(self.key, r) - 1
        lix = bisect_left(self.key, l) - 1
        # (lix, rix]になるのに注意
        rv = self.bit.sum(rix)
        lv = self.bit.sum(lix)
        delta = rv - lv
        tv = lv+1
        tix = lix*1

        vix = 0
        rmvix = 0
        vals = [0]*delta
        rmvk = [0]*delta
        rmvv = [0]*delta
        while delta:
            OK = self.bit.bisect_left(tv)
            c = self.bit.sum(OK)
            d = c - tv + 1
            for _ in range(d):
                vals[vix] = self.key[OK]
                vix += 1
            rmvk[rmvix] = OK
            rmvv[rmvix] = d
            rmvix += 1
            tv += d
            tix = OK
            delta -= d

        for i in range(rmvix):
            self.bit.add(rmvk[i], -rmvv[i])
        return vals

N, M = inpl()
Q = sorted([inpl() for _ in range(N)], key=itemgetter(2))
D = [int(input()) for _ in range(M)]
rD = {v:i for i, v in enumerate(D)}
ans = [-1]*(M)
 
dmap = DammySet(D)
 
for s, t, x in Q:
    val = dmap.pop_vals(s-x, t-1-x)
    for v in val:
        ans[rD[v]] = x
 
print(*ans, sep="\n")