import sys

input = sys.stdin.readline

from bisect import bisect_left



# 区間更新 1点取得

class SegmentTree:

    def __init__(self, N):

        tmp = 1

        while tmp < N:

            tmp <<= 1

        # self.N : 完全二分木の葉の数(N以上の最小の2べき)

        self.N = tmp

        # 2*self.N - 1 : 完全二分木のノード数

        # 1-indexedで管理するので1プラス

        self.data = [float('inf') for _ in range(2*self.N)]



    # [l, r)

    # 入力は0-indexedなので注意

    def update(self, l, r, x):

        L = l + self.N

        R = r + self.N

        while L < R:

            if L & 1:

                self.data[L] = min([self.data[L], x])

                L += 1

            if R & 1:

                R -= 1

                self.data[R] = min([self.data[R], x])

            L >>= 1

            R >>= 1



    def query(self, k):

        k += self.N

        res = self.data[k]

        while k != 1:

            k >>= 1

            res = min(res, self.data[k])

        return res







def main():

    N, Q = list(map(int, input().split()))

    road = []

    for _ in range(N):

        S, T, X = list(map(int, input().split()))

        road.append((S,T,X))



    D = [int(eval(input())) for _ in range(Q)]



    st = SegmentTree(Q)

    for S, T, X in road:

        l = bisect_left(D, S - X)

        r = bisect_left(D, T - X)

        st.update(l, r, X)



    for q in range(Q):

        ans = st.query(q)

        if ans == float('inf'):

            print((-1))

        else:

            print(ans)



if __name__ == "__main__":

    main()
from bisect import bisect_left

import sys

input = sys.stdin.readline



class SegmentTree():

    def __init__(self,size,func,default):

        self.leaf=2**(size-1).bit_length()

        self.data=[default]*(2*self.leaf-1)

        self.f=func; self.d=default

    def rangeupdate(self,l,r,x):

        l+=self.leaf-1; r+=self.leaf-1

        while l<r:

            if not l&1:

                self.data[l]=self.f(self.data[l],x)

                l+=1

            if not r&1:

                r-=1

                self.data[r]=self.f(self.data[r],x)

            l>>=1; r>>=1

    def getvalue(self,i):

        k=i+self.leaf-1

        ret=self.d

        while k>=0:

            ret=self.f(ret,self.data[k])

            k=(k-1)>>1

        return ret



#最大値            

def segfunc(x,y):

    return max(x,y)



#最小値

def segfunc2(x,y):

    return min(x,y)

#和

def segfunc3(x,y):

    return x | y





def main():

    N, Q = list(map(int, input().split()))

    construction = []

    for _ in range(N):

        S, T, X = list(map(int, input().split()))

        construction.append([S,T,X])



    D = [int(eval(input())) for _ in range(Q)]

    seg = SegmentTree(Q,segfunc2,float('inf'))



    for i in range(N):

        S, T, X = construction[i]

        l = bisect_left(D, S - X)

        r = bisect_left(D, T - X)

        seg.rangeupdate(l, r, X)

    

    for q in range(Q):

        ans = seg.getvalue(q)

        if ans == float('inf'):

            print((-1))

        else:

            print(ans)



if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline
from bisect import bisect_left

# 区間更新 1点取得
class SegmentTree:
    def __init__(self, N):
        tmp = 1
        while tmp < N:
            tmp <<= 1
        # self.N : 完全二分木の葉の数(N以上の最小の2べき)
        self.N = tmp
        # 2*self.N - 1 : 完全二分木のノード数
        # 1-indexedで管理するので1プラス
        self.data = [float("inf") for _ in range(2 * self.N)]

    # [l, r)
    # 入力は0-indexedなので注意
    def update(self, l, r, x):
        L = l + self.N
        R = r + self.N
        while L < R:
            if L & 1:
                self.data[L] = min([self.data[L], x])
                L += 1
            if R & 1:
                R -= 1
                self.data[R] = min([self.data[R], x])
            L >>= 1
            R >>= 1

    def query(self, k):
        k += self.N
        res = self.data[k]
        while k != 1:
            k >>= 1
            res = min(res, self.data[k])
        return res


def main():
    N, Q = list(map(int, input().split()))
    road = []
    for _ in range(N):
        S, T, X = list(map(int, input().split()))
        road.append((S, T, X))
    D = [int(eval(input())) for _ in range(Q)]
    st = SegmentTree(Q)
    for S, T, X in road:
        l = bisect_left(D, S - X)
        r = bisect_left(D, T - X)
        st.update(l, r, X)
    for q in range(Q):
        ans = st.query(q)
        if ans == float("inf"):
            print((-1))
        else:
            print(ans)


if __name__ == "__main__":
    main()

from bisect import bisect_left
import sys

input = sys.stdin.readline


class SegmentTree:
    def __init__(self, size, func, default):
        self.leaf = 2 ** (size - 1).bit_length()
        self.data = [default] * (2 * self.leaf - 1)
        self.f = func
        self.d = default

    def rangeupdate(self, l, r, x):
        l += self.leaf - 1
        r += self.leaf - 1
        while l < r:
            if not l & 1:
                self.data[l] = self.f(self.data[l], x)
                l += 1
            if not r & 1:
                r -= 1
                self.data[r] = self.f(self.data[r], x)
            l >>= 1
            r >>= 1

    def getvalue(self, i):
        k = i + self.leaf - 1
        ret = self.d
        while k >= 0:
            ret = self.f(ret, self.data[k])
            k = (k - 1) >> 1
        return ret


# 最大値
def segfunc(x, y):
    return max(x, y)


# 最小値
def segfunc2(x, y):
    return min(x, y)


# 和
def segfunc3(x, y):
    return x | y


def main():
    N, Q = list(map(int, input().split()))
    construction = []
    for _ in range(N):
        S, T, X = list(map(int, input().split()))
        construction.append([S, T, X])
    D = [int(eval(input())) for _ in range(Q)]
    seg = SegmentTree(Q, segfunc2, float("inf"))
    for i in range(N):
        S, T, X = construction[i]
        l = bisect_left(D, S - X)
        r = bisect_left(D, T - X)
        seg.rangeupdate(l, r, X)
    for q in range(Q):
        ans = seg.getvalue(q)
        if ans == float("inf"):
            print((-1))
        else:
            print(ans)


if __name__ == "__main__":
    main()

+from bisect import bisect_left -from bisect import bisect_left -# 区間更新 1点取得 + -    def __init__(self, N): -        tmp = 1 -        while tmp < N: -            tmp <<= 1 -        # self.N : 完全二分木の葉の数(N以上の最小の2べき) -        self.N = tmp -        # 2*self.N - 1 : 完全二分木のノード数 -        # 1-indexedで管理するので1プラス -        self.data = [float("inf") for _ in range(2 * self.N)] +    def __init__(self, size, func, default): +        self.leaf = 2 ** (size - 1).bit_length() +        self.data = [default] * (2 * self.leaf - 1) +        self.f = func +        self.d = default -    # [l, r) -    # 入力は0-indexedなので注意 -    def update(self, l, r, x): -        L = l + self.N -        R = r + self.N -        while L < R: -            if L & 1: -                self.data[L] = min([self.data[L], x]) -                L += 1 -            if R & 1: -                R -= 1 -                self.data[R] = min([self.data[R], x]) -            L >>= 1 -            R >>= 1 +    def rangeupdate(self, l, r, x): +        l += self.leaf - 1 +        r += self.leaf - 1 +        while l < r: +            if not l & 1: +                self.data[l] = self.f(self.data[l], x) +                l += 1 +            if not r & 1: +                r -= 1 +                self.data[r] = self.f(self.data[r], x) +            l >>= 1 +            r >>= 1 -    def query(self, k): -        k += self.N -        res = self.data[k] -        while k != 1: -            k >>= 1 -            res = min(res, self.data[k]) -        return res +    def getvalue(self, i): +        k = i + self.leaf - 1 +        ret = self.d +        while k >= 0: +            ret = self.f(ret, self.data[k]) +            k = (k - 1) >> 1 +        return ret + + +# 最大値 +def segfunc(x, y): +    return max(x, y) + + +# 最小値 +def segfunc2(x, y): +    return min(x, y) + + +# 和 +def segfunc3(x, y): +    return x | y -    road = [] +    construction = [] -        road.append((S, T, X)) +        construction.append([S, T, X]) -    st = SegmentTree(Q) -    for S, T, X in road: +    seg = SegmentTree(Q, segfunc2, float("inf")) +    for i in range(N): +        S, T, X = construction[i] -        st.update(l, r, X) +        seg.rangeupdate(l, r, X) -        ans = st.query(q) +        ans = seg.getvalue(q)