class AVLtree:
    """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """
 
    def __init__(self):
        self.root = None
        self.num = 0
        
    def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
    def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
    def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
    def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
    def __len__(self):
        return self.num

    def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
    def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff


class Node:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
    def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
    def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
    def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
    def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                    

n,q = map(int, input().split())
e = []
for i in range(n):
  s,t,x = map(int, input().split())
  e.append((s-x,x,i))
  e.append((t-x,x,i))
e.sort(key=lambda x:x[0])
D = [int(input()) for _ in range(q)]
avl = AVLtree()
ans = []
f = [0]*n
j = 0
N = 2*n
for d in D:
  while j < N and e[j][0] <= d:
    _,x,i = e[j]
    if f[i]:
      avl.erase((x,i))
    else:
      avl.insert((x,i))
      f[i] = 1
    j += 1
  m = avl.lower_bound((-float("inf"),0))
  ans.append(m[0] if m != float("inf") else -1)

for i in ans:
  print(i) class AVLtree:
    """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """
 
    def __init__(self):
        self.root = None
        self.num = 0
        
    def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
    def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
    def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
    def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
    def __len__(self):
        return self.num

    def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
    def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff AVLtree """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """ def __init__(self):
        self.root = None
        self.num = 0
        
     __init__ self.root = None self.root self root None self.num = 0 self.num self num 0 self self def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
     insert if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
         self.root is None self.root self root None self.root = Node(x) self.root self root Node(x) Node x self.num += 1 self.num self num 1 return q = [] q [] node = self.root node self.root self root while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
         True if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
         node.val == x node.val node val x return elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
             x < node.val x node.val node val q.append((node, 1)) q.append q append (node, 1) node 1 if node.left is None:
                    node.left = Node(x)
                    break
                 node.left is None node.left node left None node.left = Node(x) node.left node left Node(x) Node x break node = node.left node node.left node left q.append((node, -1)) q.append q append (node, -1) node -1 if node.right is None:
                    node.right = Node(x)
                    break
                 node.right is None node.right node right None node.right = Node(x) node.right node right Node(x) Node x break node = node.right node node.right node right self.num += 1 self.num self num 1 new_node = None new_node None while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
         q node, key = q.pop() node q.pop() q.pop q pop key node.bal += key node.bal node bal key node.size += 1 node.size node size 1 bal = node.bal bal node.bal node bal if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
             not bal bal while q:
                    node, key = q.pop()
                    node.size += 1
                 q node, key = q.pop() node q.pop() q.pop q pop key node.size += 1 node.size node size 1 return if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
         bal == 2 bal 2 if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                 node.left.bal == -1 node.left.bal node.left node left bal -1 node.left = node.left._rotateL() node.left node left node.left._rotateL() node.left._rotateL node.left node left _rotateL new_node = node._rotateR() new_node node._rotateR() node._rotateR node _rotateR new_node._update_bal() new_node._update_bal new_node _update_bal new_node = node._rotateR() new_node node._rotateR() node._rotateR node _rotateR new_node.bal = 0 new_node.bal new_node bal 0 node.bal = 0 node.bal node bal 0 break elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
         bal == -2 bal -2 if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                 node.right.bal == 1 node.right.bal node.right node right bal 1 node.right = node.right._rotateR() node.right node right node.right._rotateR() node.right._rotateR node.right node right _rotateR new_node = node._rotateL() new_node node._rotateL() node._rotateL node _rotateL new_node._update_bal() new_node._update_bal new_node _update_bal new_node = node._rotateL() new_node node._rotateL() node._rotateL node _rotateL new_node.bal = 0 new_node.bal new_node bal 0 node.bal = 0 node.bal node bal 0 break if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
         q node, key = q.pop() node q.pop() q.pop q pop key node.size += 1 node.size node size 1 if key == 1:
                node.left = new_node
            else:
                node.right = new_node
         key == 1 key 1 node.left = new_node node.left node left new_node node.right = new_node node.right node right new_node elif new_node is not None:
            self.root = new_node
         new_node is not None new_node None self.root = new_node self.root self root new_node while q:
            node, key = q.pop()
            node.size += 1

            
     q node, key = q.pop() node q.pop() q.pop q pop key node.size += 1 node.size node size 1 self self x x def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
     erase if self.root is None:
            return
         self.root is None self.root self root None return q = [] q [] node = self.root node self.root self root while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

         node is not None node None if node.val == x:
                break
             node.val == x node.val node val x break if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
         x < node.val x node.val node val q.append((node, 1)) q.append q append (node, 1) node 1 node = node.left node node.left node left q.append((node, -1)) q.append q append (node, -1) node -1 node = node.right node node.right node right return self.num -= 1 self.num self num 1 if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
         node.left is not None and node.right is not None node.left is not None node.left node left None node.right is not None node.right node right None q.append((node, -1)) q.append q append (node, -1) node -1 min_node = node.right min_node node.right node right while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
             min_node.left is not None min_node.left min_node left None q.append((min_node, 1)) q.append q append (min_node, 1) min_node 1 min_node = min_node.left min_node min_node.left min_node left node.val = min_node.val node.val node val min_node.val min_node val node = min_node node min_node if q:
            pre, key = q[-1]
        else:
            pre = None
         q pre, key = q[-1] pre q[-1] q -1 key pre = None pre None if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
         node.left is None node.left node left None cnode = node.right cnode node.right node right cnode = node.left cnode node.left node left if pre is None:
            self.root = cnode
            return
         pre is None pre None self.root = cnode self.root self root cnode return if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
         key == 1 key 1 pre.left = cnode pre.left pre left cnode pre.right = cnode pre.right pre right cnode while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
         q new_node = None new_node None node, key = q.pop() node q.pop() q.pop q pop key node.bal -= key node.bal node bal key node.size -= 1 node.size node size 1 bal = node.bal bal node.bal node bal if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
             bal == 2 bal 2 if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
             node.left.bal == -1 node.left.bal node.left node left bal -1 node.left = node.left._rotateL() node.left node left node.left._rotateL() node.left._rotateL node.left node left _rotateL new_node = node._rotateR() new_node node._rotateR() node._rotateR node _rotateR new_node._update_bal() new_node._update_bal new_node _update_bal new_node = node._rotateR() new_node node._rotateR() node._rotateR node _rotateR if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
             not new_node.bal new_node.bal new_node bal new_node.bal = -1 new_node.bal new_node bal -1 node.bal = 1 node.bal node bal 1 new_node.bal = 0 new_node.bal new_node bal 0 node.bal = 0 node.bal node bal 0 elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
             bal == -2 bal -2 if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
             node.right.bal == 1 node.right.bal node.right node right bal 1 node.right = node.right._rotateR() node.right node right node.right._rotateR() node.right._rotateR node.right node right _rotateR new_node = node._rotateL() new_node node._rotateL() node._rotateL node _rotateL new_node._update_bal() new_node._update_bal new_node _update_bal new_node = node._rotateL() new_node node._rotateL() node._rotateL node _rotateL if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
             not new_node.bal new_node.bal new_node bal new_node.bal = 1 new_node.bal new_node bal 1 node.bal = -1 node.bal node bal -1 new_node.bal= 0 new_node.bal new_node bal 0 node.bal = 0 node.bal node bal 0 elif bal:
                break
             bal break if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
         new_node is not None new_node None if not q:
                    self.root = new_node
                    return
                 not q q self.root = new_node self.root self root new_node return node, key = q[-1] node q[-1] q -1 key if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                 key == 1 key 1 node.left = new_node node.left node left new_node node.right = new_node node.right node right new_node if new_node.bal:
                    break
         new_node.bal new_node bal break while q:
            node, key = q.pop()
            node.size -= 1
                    
     q node, key = q.pop() node q.pop() q.pop q pop key node.size -= 1 node.size node size 1 self self x x def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
     lower_bound res = float("inf") res float("inf") float "inf" node = self.root node self.root self root while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
         node is not None node None if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
         x <= node.val x node.val node val res = node.val res node.val node val node = node.left node node.left node left node = node.right node node.right node right return res res self self x x def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
     upper_bound res = -float("inf") res -float("inf") float("inf") float "inf" node = self.root node self.root self root while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
         node is not None node None if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
         x <= node.val x node.val node val node = node.left node node.left node left res = node.val res node.val node val node = node.right node node.right node right return res res self self x x def __len__(self):
        return self.num

     __len__ return self.num self.num self num self self def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
     __getitem__ if key < 0:
            key += self.num
         key < 0 key 0 key += self.num key self.num self num key += 1 key 1 node = self.root node self.root self root while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
         True idx = node.left.size + 1 if node.left is not None else 1 idx node.left.size + 1 if node.left is not None else 1 node.left is not None node.left node left None node.left.size + 1 node.left.size node.left node left size 1 1 if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
         idx <= key idx key key -= idx key idx if not key:
                    break
                 not key key break node = node.right node node.right node right node = node.left node node.left node left return node.val node.val node val self self key key def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff __str__ if self.root is None:
            return "[]"
         self.root is None self.root self root None return "[]" "[]" buff = "[" buff "[" for x in self.root._dfs():
            buff += str(x)+", "
         x self.root._dfs() self.root._dfs self.root self root _dfs buff += str(x)+", " buff str(x)+", " str(x) str x ", " buff = buff.rstrip(", ") buff buff.rstrip(", ") buff.rstrip buff rstrip ", " buff += "]" buff "]" return buff buff self self class Node:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
    def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
    def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
    def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
    def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     Node def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
     __init__ self.val = x self.val self val x self.left = None self.left self left None self.right = None self.right self right None self.bal = 0 self.bal self bal 0 self.size = 1 self.size self size 1 self self x x def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
     _rotateR nodeL = self.left nodeL self.left self left nodeLL_size = nodeL.left.size if nodeL.left is not None else 0 nodeLL_size nodeL.left.size if nodeL.left is not None else 0 nodeL.left is not None nodeL.left nodeL left None nodeL.left.size nodeL.left nodeL left size 0 nodeR_size = self.right.size if self.right is not None else 0 nodeR_size self.right.size if self.right is not None else 0 self.right is not None self.right self right None self.right.size self.right self right size 0 self.size -= nodeLL_size + 1 self.size self size nodeLL_size + 1 nodeLL_size 1 nodeL.size += nodeR_size + 1 nodeL.size nodeL size nodeR_size + 1 nodeR_size 1 self.left = nodeL.right self.left self left nodeL.right nodeL right nodeL.right = self nodeL.right nodeL right self return nodeL nodeL self self def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
     _rotateL nodeR = self.right nodeR self.right self right nodeRR_size = nodeR.right.size if nodeR.right is not None else 0 nodeRR_size nodeR.right.size if nodeR.right is not None else 0 nodeR.right is not None nodeR.right nodeR right None nodeR.right.size nodeR.right nodeR right size 0 nodeL_size = self.left.size if self.left is not None else 0 nodeL_size self.left.size if self.left is not None else 0 self.left is not None self.left self left None self.left.size self.left self left size 0 self.size -= nodeRR_size + 1 self.size self size nodeRR_size + 1 nodeRR_size 1 nodeR.size += nodeL_size + 1 nodeR.size nodeR size nodeL_size + 1 nodeL_size 1 self.right = nodeR.left self.right self right nodeR.left nodeR left nodeR.left = self nodeR.left nodeR left self return nodeR nodeR self self def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
     _update_bal if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
         self.bal == 1 self.bal self bal 1 self.right.bal = -1 self.right.bal self.right self right bal -1 self.left.bal = 0 self.left.bal self.left self left bal 0 elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
         self.bal == -1 self.bal self bal -1 self.right.bal = 0 self.right.bal self.right self right bal 0 self.left.bal = 1 self.left.bal self.left self left bal 1 self.right.bal = 0 self.right.bal self.right self right bal 0 self.left.bal = 0 self.left.bal self.left self left bal 0 self.bal = 0 self.bal self bal 0 self self def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     _dfs if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     self is not None self None if self.left is not None:
                for x in self.left._dfs():
                    yield x
             self.left is not None self.left self left None for x in self.left._dfs():
                    yield x
             x self.left._dfs() self.left._dfs self.left self left _dfs yield x x yield self.val self.val self val if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     self.right is not None self.right self right None for x in self.right._dfs():
                    yield x
                     x self.right._dfs() self.right._dfs self.right self right _dfs yield x x self self n,q = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split q e = [] e [] for i in range(n):
  s,t,x = map(int, input().split())
  e.append((s-x,x,i))
  e.append((t-x,x,i)) i 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 e.append((s-x,x,i)) e.append e append (s-x,x,i) s-x s x x i e.append((t-x,x,i)) e.append e append (t-x,x,i) t-x t x x i e.sort(key=lambda x:x[0]) e.sort e sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x int(input()) for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) int(input()) int input() input D = [int(input()) for _ in range(q)] D [int(input()) for _ in range(q)] avl = AVLtree() avl AVLtree() AVLtree ans = [] ans [] f = [0]*n f [0]*n [0] 0 n j = 0 j 0 N = 2*n N 2*n 2 n for d in D:
  while j < N and e[j][0] <= d:
    _,x,i = e[j]
    if f[i]:
      avl.erase((x,i))
    else:
      avl.insert((x,i))
      f[i] = 1
    j += 1
  m = avl.lower_bound((-float("inf"),0))
  ans.append(m[0] if m != float("inf") else -1) d D while j < N and e[j][0] <= d:
    _,x,i = e[j]
    if f[i]:
      avl.erase((x,i))
    else:
      avl.insert((x,i))
      f[i] = 1
    j += 1
   j < N and e[j][0] <= d j < N j N e[j][0] <= d e[j][0] [j] e j 0 d _,x,i = e[j] _ e[j] e j x i if f[i]:
      avl.erase((x,i))
    else:
      avl.insert((x,i))
      f[i] = 1
     f[i] f i avl.erase((x,i)) avl.erase avl erase (x,i) x i avl.insert((x,i)) avl.insert avl insert (x,i) x i f[i] = 1 f[i] f i 1 j += 1 j 1 m = avl.lower_bound((-float("inf"),0)) m avl.lower_bound((-float("inf"),0)) avl.lower_bound avl lower_bound (-float("inf"),0) -float("inf") float("inf") float "inf" 0 ans.append(m[0] if m != float("inf") else -1) ans.append ans append m[0] if m != float("inf") else -1 m != float("inf") m float("inf") float "inf" m[0] m 0 -1 for i in ans:
  print(i) i ans print(i) print i s,t,x = map(int, input().split()) map(int, input().split()) s j = 0 0 j class AVLtree:
    """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """
 
    def __init__(self):
        self.root = None
        self.num = 0
        
    def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
    def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
    def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
    def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
    def __len__(self):
        return self.num

    def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
    def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff class AVLtree:
    """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """
 
    def __init__(self):
        self.root = None
        self.num = 0
        
    def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
    def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
    def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
    def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
    def __len__(self):
        return self.num

    def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
    def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff AVLtree x,i = e[j] e[j] x f = [0]*n [0]*n f _,x,i = e[j] e[j] _ m = avl.lower_bound((-float("inf"),0)) avl.lower_bound((-float("inf"),0)) m D = [int(input()) for _ in range(q)] [int(input()) for _ in range(q)] D q = map(int, input().split()) map(int, input().split()) q t,x = map(int, input().split()) map(int, input().split()) t ans = [] [] ans e = [] [] e N = 2*n 2*n N x = map(int, input().split()) map(int, input().split()) x i = e[j] e[j] i class Node:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
    def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
    def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
    def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
    def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     class Node:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
    def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
    def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
    def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
    def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                     Node n,q = map(int, input().split()) map(int, input().split()) n avl = AVLtree() AVLtree() avl j += 1 1 j
class AVLtree:
    """
    参考：http://www.nct9.ne.jp/m_hiroi/light/pyalgo12.html
    insert : 挿入
    erase : 削除
    lower_bound(x) : x <= v なる最小のv、なければ-float("inf")、最小値はlower(-float("inf"))
    upper_bound(x) : v < x なる最大のv、なければfloat("inf")、最大値はupper(float("inf"))
    print(avltree) : デバッグ用
    """
 
    def __init__(self):
        self.root = None
        self.num = 0
        
    def insert(self, x):
        if self.root is None:
            self.root = Node(x)
            self.num += 1
            return
        q = []
        node = self.root
        while True:
            if node.val == x:
                return
            elif x < node.val:
                q.append((node, 1))
                if node.left is None:
                    node.left = Node(x)
                    break
                node = node.left
            else:
                q.append((node, -1))
                if node.right is None:
                    node.right = Node(x)
                    break
                node = node.right
        self.num += 1
        
        # バランス調整
        new_node = None
        while q:
            node, key = q.pop()
            node.bal += key
            node.size += 1
            bal = node.bal
            if not bal:
                while q:
                    node, key = q.pop()
                    node.size += 1
                return
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    new_node.bal = 0
                    node.bal = 0
                break
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    new_node.bal = 0
                    node.bal = 0
                break
        if q:
            node, key = q.pop()
            node.size += 1
            if key == 1:
                node.left = new_node
            else:
                node.right = new_node
        elif new_node is not None:
            self.root = new_node
        while q:
            node, key = q.pop()
            node.size += 1

            
    def erase(self, x):
        if self.root is None:
            return
        q = []
        node = self.root
        while node is not None:
            if node.val == x:
                break
            if x < node.val:
                q.append((node, 1))
                node = node.left
            else:
                q.append((node, -1))
                node = node.right
        else:
            return

        self.num -= 1
        if node.left is not None and node.right is not None:
            q.append((node, -1))
            min_node = node.right
            while min_node.left is not None:
                q.append((min_node, 1))
                min_node = min_node.left
            node.val = min_node.val
            node = min_node
        if q:
            pre, key = q[-1]
        else:
            pre = None
        if node.left is None:
            cnode = node.right
        else:
            cnode = node.left
        if pre is None:
            self.root = cnode
            return
        if key == 1:
            pre.left = cnode
        else:
            pre.right = cnode
        
        # バランス調整
        while q:
            new_node = None
            node, key = q.pop()
            node.bal -= key
            node.size -= 1
            bal = node.bal
            if bal == 2:
                if node.left.bal == -1:
                    node.left = node.left._rotateL()
                    new_node = node._rotateR()
                    new_node._update_bal()
                else:
                    new_node = node._rotateR()
                    if not new_node.bal:
                        new_node.bal = -1
                        node.bal = 1
                    else:
                        new_node.bal = 0
                        node.bal = 0
            elif bal == -2:
                if node.right.bal == 1:
                    node.right = node.right._rotateR()
                    new_node = node._rotateL()
                    new_node._update_bal()
                else:
                    new_node = node._rotateL()
                    if not new_node.bal:
                        new_node.bal = 1
                        node.bal = -1
                    else:
                        new_node.bal= 0
                        node.bal = 0
            elif bal:
                break
            if new_node is not None:
                if not q:
                    self.root = new_node
                    return
                node, key = q[-1]
                if key == 1:
                    node.left = new_node
                else:
                    node.right = new_node
                if new_node.bal:
                    break
        while q:
            node, key = q.pop()
            node.size -= 1
                    
    def lower_bound(self, x):
        res = float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                res = node.val
                node = node.left
            else:
                node = node.right
        return res
    
    
    def upper_bound(self, x):
        res = -float("inf")
        node = self.root
        while node is not None:
            if x <= node.val:
                node = node.left
            else:
                res = node.val
                node = node.right
        return res
    
    def __len__(self):
        return self.num

    def __getitem__(self, key):
        if key < 0:
            key += self.num
        key += 1
        node = self.root
        while True:
            idx = node.left.size + 1 if node.left is not None else 1
            if idx <= key:
                key -= idx
                if not key:
                    break
                node = node.right
            else:
                node = node.left
        return node.val

    
    def __str__(self):
        if self.root is None:
            return "[]"
        buff = "["
        for x in self.root._dfs():
            buff += str(x)+", "
        buff = buff.rstrip(", ")
        buff += "]"
        return buff


class Node:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None
        self.bal = 0 #1:左1, -1:右1
        self.size = 1
    
    def _rotateR(self):
        nodeL = self.left
        nodeLL_size = nodeL.left.size if nodeL.left is not None else 0
        nodeR_size = self.right.size if self.right is not None else 0
        self.size -= nodeLL_size + 1
        nodeL.size += nodeR_size + 1
        self.left = nodeL.right
        nodeL.right = self
        return nodeL
    
    
    def _rotateL(self):
        nodeR = self.right
        nodeRR_size = nodeR.right.size if nodeR.right is not None else 0
        nodeL_size = self.left.size if self.left is not None else 0
        self.size -= nodeRR_size + 1
        nodeR.size += nodeL_size + 1
        self.right = nodeR.left
        nodeR.left = self
        return nodeR
    
    
    def _update_bal(self):
        if self.bal == 1:
            self.right.bal = -1
            self.left.bal = 0
        elif self.bal == -1:
            self.right.bal = 0
            self.left.bal = 1
        else:
            self.right.bal = 0
            self.left.bal = 0
        self.bal = 0
    
    
    def _dfs(self):
        if self is not None:
            if self.left is not None:
                for x in self.left._dfs():
                    yield x
            yield self.val
            if self.right is not None:
                for x in self.right._dfs():
                    yield x
                    

n,q = map(int, input().split())
e = []
for i in range(n):
  s,t,x = map(int, input().split())
  e.append((s-x,x,i))
  e.append((t-x,x,i))
e.sort(key=lambda x:x[0])
D = [int(input()) for _ in range(q)]
avl = AVLtree()
ans = []
f = [0]*n
j = 0
N = 2*n
for d in D:
  while j < N and e[j][0] <= d:
    _,x,i = e[j]
    if f[i]:
      avl.erase((x,i))
    else:
      avl.insert((x,i))
      f[i] = 1
    j += 1
  m = avl.lower_bound((-float("inf"),0))
  ans.append(m[0] if m != float("inf") else -1)

for i in ans:
  print(i)
