def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return

def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return

def examD():
    def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
    N, Q = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    W = [0] * N
    for _ in range(Q):
        p, x = LI()
        W[p-1] += x
    ans = bfs(N,V,0,W)
    print(" ".join(map(str,ans)))
    return

def examE():
    def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    F = bfs(N,V,0)
    S = bfs(N,V,N-1)
    f = 0; s = 0
    for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
    if f>s:
        print("Fennec")
    else:
        print("Snuke")
    return

def examF():
    # 区間加算、上書き、一点取得
    class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

    N, Q = LI()
    X = []
    for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
    D = [I()for _ in range(Q)]
    seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b))
    for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
    ans = []
    for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
    for v in ans:
        print(v)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examF()

"""

""" def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return examA def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
     calc_L return ((x2-x1)**2 + (y2-y1)**2)**0.5 ((x2-x1)**2 + (y2-y1)**2)**0.5 (x2-x1)**2 + (y2-y1)**2 (x2-x1)**2 x2-x1 x2 x1 2 (y2-y1)**2 y2-y1 y2 y1 2 0.5 x1 x1 y1 y1 x2 x2 y2 y2 N = I() N I() I LI()for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) LI() LI X = [LI()for _ in range(N)] X [LI()for _ in range(N)] ans = 0 ans 0 for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
     x itertools.permutations(X) itertools.permutations itertools permutations X cur = 0 cur 0 for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
         i range(1,N) range 1 N cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1]) cur calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1]) calc_L x[i-1][0] [i-1] x i-1 i 1 0 x[i-1][1] [i-1] x i-1 i 1 1 x[i][0] [i] x i 0 x[i][1] [i] x i 1 ans += cur ans cur for i in range(1,N+1):
        ans /= i
     i range(1,N+1) range 1 N+1 N 1 ans /= i ans i print(ans) print ans return def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return examB def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
     judge sn = 0 sn 0 for i in n:
            sn += int(i)
         i n sn += int(i) sn int(i) int i if int(n)%sn==0:
            return "Yes"
         int(n)%sn==0 int(n)%sn int(n) int n sn 0 return "Yes" "Yes" return "No" "No" n n N = SI() N SI() SI ans = judge(N) ans judge(N) judge N print(ans) print ans return def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return examC N, K = LI() N LI() LI K P = LI() P LI() LI ans = 0 ans 0 S = [0]*(N+1) S [0]*(N+1) [0] 0 N+1 N 1 for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
     i range(N) range N S[i+1] = S[i]+(P[i]+1)/2 S[i+1] S i+1 i 1 S[i]+(P[i]+1)/2 S[i] S i (P[i]+1)/2 P[i]+1 P[i] P i 1 2 for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
     i range(N-K+1) range N-K+1 N-K N K 1 cur = S[i+K] - S[i] cur S[i+K] - S[i] S[i+K] S i+K i K S[i] S i if cur>ans:
            ans = cur
     cur>ans cur ans ans = cur ans cur print(ans) print ans return def examD():
    def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
    N, Q = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    W = [0] * N
    for _ in range(Q):
        p, x = LI()
        W[p-1] += x
    ans = bfs(N,V,0,W)
    print(" ".join(map(str,ans)))
    return examD def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
     bfs visited = [False]*n visited [False]*n [False] False n que = deque() que deque() deque que.append(s) que.append que append s while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
         que now = que.pop() now que.pop() que.pop que pop visited[now] = True visited[now] visited now True for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
         ne V[now] V now if visited[ne]:
                    continue
                 visited[ne] visited ne continue W[ne] += W[now] W[ne] W ne W[now] W now que.append(ne) que.append que append ne return W W n n V V s s W W N, Q = LI() N LI() LI Q []for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] V = [[]for _ in range(N)] V [[]for _ in range(N)] for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
     _ range(N-1) range N-1 N 1 a, b = LI() a LI() LI b a -= 1 a 1 b -= 1 b 1 V[a].append(b) [a].append [a] V a append b V[b].append(a) [b].append [b] V b append a W = [0] * N W [0] * N [0] 0 N for _ in range(Q):
        p, x = LI()
        W[p-1] += x
     _ range(Q) range Q p, x = LI() p LI() LI x W[p-1] += x W[p-1] W p-1 p 1 x ans = bfs(N,V,0,W) ans bfs(N,V,0,W) bfs N V 0 W print(" ".join(map(str,ans))) print " ".join(map(str,ans)) " ".join " " join map(str,ans) map str ans return def examE():
    def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    F = bfs(N,V,0)
    S = bfs(N,V,N-1)
    f = 0; s = 0
    for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
    if f>s:
        print("Fennec")
    else:
        print("Snuke")
    return examE def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
     bfs L = [inf]*n L [inf]*n [inf] inf n que = deque() que deque() deque que.append(s) que.append que append s L[s] = 0 L[s] L s 0 while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
         que now = que.popleft() now que.popleft() que.popleft que popleft for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
         ne edges[now] edges now if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
         L[ne]>L[now]+1 L[ne] L ne L[now]+1 L[now] L now 1 L[ne] = L[now]+1 L[ne] L ne L[now]+1 L[now] L now 1 que.append(ne) que.append que append ne return L L n n edges edges s s N = I() N I() I []for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] V = [[]for _ in range(N)] V [[]for _ in range(N)] for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
     _ range(N-1) range N-1 N 1 a, b = LI() a LI() LI b a -= 1 a 1 b -= 1 b 1 V[a].append(b) [a].append [a] V a append b V[b].append(a) [b].append [b] V b append a F = bfs(N,V,0) F bfs(N,V,0) bfs N V 0 S = bfs(N,V,N-1) S bfs(N,V,N-1) bfs N V N-1 N 1 f = 0 f 0 s = 0 s 0 for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
     i range(N) range N if F[i]>S[i]:
            s += 1
        else:
            f += 1
     F[i]>S[i] F[i] F i S[i] S i s += 1 s 1 f += 1 f 1 if f>s:
        print("Fennec")
    else:
        print("Snuke")
     f>s f s print("Fennec") print "Fennec" print("Snuke") print "Snuke" return def examF():
    # 区間加算、上書き、一点取得
    class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

    N, Q = LI()
    X = []
    for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
    D = [I()for _ in range(Q)]
    seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b))
    for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
    ans = []
    for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
    for v in ans:
        print(v)
    return examF class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

     SegmentTree def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

         __init__ self.ide_ele = ele self.ide_ele self ide_ele ele self.segfun = segfun self.segfun self segfun segfun self.n = n self.n self n n self.N0 = 1 << n.bit_length() self.N0 self N0 1 << n.bit_length() 1 n.bit_length() n.bit_length n bit_length self.data = [self.ide_ele] * (self.N0 * 2) self.data self data [self.ide_ele] * (self.N0 * 2) [self.ide_ele] self.ide_ele self ide_ele self.N0 * 2 self.N0 self N0 2 self self n n ele ele segfun segfun def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

         update_add l += self.N0 l self.N0 self N0 r += self.N0 r self.N0 self N0 while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

         l < r l r if l & 1:
                    self.data[l] += val
                    l += 1
                 l & 1 l 1 self.data[l] += val self.data[l] self.data self data l val l += 1 l 1 if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                 r & 1 r 1 self.data[r - 1] += val self.data[r - 1] self.data self data r - 1 r 1 val r -= 1 r 1 l //= 2 l 2 r //= 2 r 2 self self l l r r val val def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

         update l += self.N0 l self.N0 self N0 r += self.N0 r self.N0 self N0 while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

         l < r l r if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                 l & 1 l 1 self.data[l] = self.segfun(self.data[l], val) self.data[l] self.data self data l self.segfun(self.data[l], val) self.segfun self segfun self.data[l] self.data self data l val l += 1 l 1 if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                 r & 1 r 1 self.data[r - 1] = self.segfun(self.data[r - 1], val) self.data[r - 1] self.data self data r - 1 r 1 self.segfun(self.data[r - 1], val) self.segfun self segfun self.data[r - 1] self.data self data r - 1 r 1 val r -= 1 r 1 l //= 2 l 2 r //= 2 r 2 self self l l r r val val def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

     query i += len(self.data) // 2 i len(self.data) // 2 len(self.data) len self.data self data 2 ret = self.data[i] ret self.data[i] self.data self data i while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
             i > 0 i 0 i //= 2 i 2 ret = self.segfun(ret, self.data[i]) ret self.segfun(ret, self.data[i]) self.segfun self segfun ret self.data[i] self.data self data i return ret ret self self i i N, Q = LI() N LI() LI Q X = [] X [] for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
     _ range(N) range N s,t,x = LI() s LI() LI t x l = max(0,s-x) l max(0,s-x) max 0 s-x s x r = t-x r t-x t x X.append([x,l,r]) X.append X append [x,l,r] x l r I()for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) I() I D = [I()for _ in range(Q)] D [I()for _ in range(Q)] seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b)) seg_min SegmentTree(Q,inf,lambda a,b:min(a,b)) SegmentTree Q inf lambda a,b:min(a,b) min(a,b) min a b a b for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
     x l r X L = bisect.bisect_left(D,l) L bisect.bisect_left(D,l) bisect.bisect_left bisect bisect_left D l R = bisect.bisect_left(D,r) R bisect.bisect_left(D,r) bisect.bisect_left bisect bisect_left D r seg_min.update(L,R,x) seg_min.update seg_min update L R x ans = [] ans [] for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
     i range(Q) range Q cur = seg_min.query(i) cur seg_min.query(i) seg_min.query seg_min query i if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
     cur==inf cur inf ans.append(-1) ans.append ans append -1 ans.append(cur) ans.append ans append cur for v in ans:
        print(v)
     v ans print(v) print v return import sys,bisect,itertools,heapq,math,random sys bisect itertools heapq math random from copy import deepcopy from heapq import heappop,heappush,heapify from collections import Counter,defaultdict,deque def I(): return int(sys.stdin.readline()) I def LI(): return list(map(int,sys.stdin.readline().split())) LI def LSI(): return list(map(str,sys.stdin.readline().split())) LSI def LS(): return sys.stdin.readline().split() LS def SI(): return sys.stdin.readline().strip() SI global mod,mod2,inf,alphabet,_ep mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 mod2 = 998244353 mod2 998244353 inf = 10**18 inf 10**18 10 18 _ep = 10**(-12) _ep 10**(-12) 10 -12 chr(ord('a') + i) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord('a') + i) chr ord('a') + i ord('a') ord 'a' i alphabet = [chr(ord('a') + i) for i in range(26)] alphabet [chr(ord('a') + i) for i in range(26)] sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 if __name__ == '__main__':
    examF() __name__ == '__main__' __name__ '__main__' examF() examF """

""" def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return examB global mod,mod2,inf,alphabet,_ep def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return examA _ep = 10**(-12) 10**(-12) _ep def SI(): return sys.stdin.readline().strip() def SI(): return sys.stdin.readline().strip() SI def examD():
    def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
    N, Q = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    W = [0] * N
    for _ in range(Q):
        p, x = LI()
        W[p-1] += x
    ans = bfs(N,V,0,W)
    print(" ".join(map(str,ans)))
    return def examD():
    def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
    N, Q = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    W = [0] * N
    for _ in range(Q):
        p, x = LI()
        W[p-1] += x
    ans = bfs(N,V,0,W)
    print(" ".join(map(str,ans)))
    return examD def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS def examE():
    def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    F = bfs(N,V,0)
    S = bfs(N,V,N-1)
    f = 0; s = 0
    for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
    if f>s:
        print("Fennec")
    else:
        print("Snuke")
    return def examE():
    def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    F = bfs(N,V,0)
    S = bfs(N,V,N-1)
    f = 0; s = 0
    for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
    if f>s:
        print("Fennec")
    else:
        print("Snuke")
    return examE inf = 10**18 10**18 inf alphabet = [chr(ord('a') + i) for i in range(26)] [chr(ord('a') + i) for i in range(26)] alphabet def LI(): return list(map(int,sys.stdin.readline().split())) def LI(): return list(map(int,sys.stdin.readline().split())) LI def LSI(): return list(map(str,sys.stdin.readline().split())) def LSI(): return list(map(str,sys.stdin.readline().split())) LSI mod = 10**9 + 7 10**9 + 7 mod mod2 = 998244353 998244353 mod2 def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return examC def examF():
    # 区間加算、上書き、一点取得
    class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

    N, Q = LI()
    X = []
    for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
    D = [I()for _ in range(Q)]
    seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b))
    for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
    ans = []
    for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
    for v in ans:
        print(v)
    return def examF():
    # 区間加算、上書き、一点取得
    class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

    N, Q = LI()
    X = []
    for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
    D = [I()for _ in range(Q)]
    seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b))
    for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
    ans = []
    for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
    for v in ans:
        print(v)
    return examF
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        #print(x,cur)
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    def judge(n):
        sn = 0
        for i in n:
            sn += int(i)
        if int(n)%sn==0:
            return "Yes"
        return "No"
    N = SI()
    ans = judge(N)
    print(ans)
    return

def examC():
    N, K = LI()
    P = LI()
    ans = 0
    S = [0]*(N+1)
    for i in range(N):
        S[i+1] = S[i]+(P[i]+1)/2
    for i in range(N-K+1):
        cur = S[i+K] - S[i]
        if cur>ans:
            ans = cur
    print(ans)
    return

def examD():
    def bfs(n,V,s,W):
        visited = [False]*n
        que = deque()
        que.append(s)
        while(que):
            now = que.pop()
            visited[now] = True
            for ne in V[now]:
                if visited[ne]:
                    continue
                W[ne] += W[now]
                que.append(ne)
        return W
    N, Q = LI()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    W = [0] * N
    for _ in range(Q):
        p, x = LI()
        W[p-1] += x
    ans = bfs(N,V,0,W)
    print(" ".join(map(str,ans)))
    return

def examE():
    def bfs(n,edges,s):
        L = [inf]*n
        que = deque()
        que.append(s)
        L[s] = 0
        while(que):
            now = que.popleft()
            for ne in edges[now]:
                if L[ne]>L[now]+1:
                    L[ne] = L[now]+1
                    que.append(ne)
        return L
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1; b -= 1
        V[a].append(b)
        V[b].append(a)
    F = bfs(N,V,0)
    S = bfs(N,V,N-1)
    f = 0; s = 0
    for i in range(N):
        if F[i]>S[i]:
            s += 1
        else:
            f += 1
    if f>s:
        print("Fennec")
    else:
        print("Snuke")
    return

def examF():
    # 区間加算、上書き、一点取得
    class SegmentTree:
        def __init__(self, n, ele, segfun):
            #####単位元######要設定0or1orinf
            self.ide_ele = ele
            self.segfun = segfun
            ####################
            self.n = n
            self.N0 = 1 << n.bit_length()
            self.data = [self.ide_ele] * (self.N0 * 2)

        def update_add(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] += val
                    l += 1
                if r & 1:
                    self.data[r - 1] += val
                    r -= 1
                l //= 2
                r //= 2

        def update(self, l, r, val):
            l += self.N0
            r += self.N0
            while l < r:
                if l & 1:
                    self.data[l] = self.segfun(self.data[l], val)
                    l += 1
                if r & 1:
                    self.data[r - 1] = self.segfun(self.data[r - 1], val)
                    r -= 1
                l //= 2
                r //= 2

        def query(self, i):
            i += len(self.data) // 2
            ret = self.data[i]
            while i > 0:
                i //= 2
                ret = self.segfun(ret, self.data[i])
            return ret

    N, Q = LI()
    X = []
    for _ in range(N):
        s,t,x = LI()
        l = max(0,s-x)
        r = t-x
        X.append([x,l,r])
    D = [I()for _ in range(Q)]
    seg_min = SegmentTree(Q,inf,lambda a,b:min(a,b))
    for x,l,r in X:
        L = bisect.bisect_left(D,l)
        R = bisect.bisect_left(D,r)
        seg_min.update(L,R,x)
    ans = []
    for i in range(Q):
        cur = seg_min.query(i)
        if cur==inf:
            ans.append(-1)
        else:
            ans.append(cur)
    for v in ans:
        print(v)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examF()

"""

"""