output_description: Print Q lines. The i-th line should contain the distance the i-th person will
  walk or -1 if that person walks forever.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N Q
      S_1 T_1 X_1
      :
      S_N T_N X_N
      D_1
      :
      D_Q
attempt: read = input
  rn = lambda: list(map(int, read().split()))
  n, q = rn()
  STX = [rn() for i in range(n)]
  D = [rn()[0] for i in range(q)]
  D = list(
      map(
          lambda tp: (
              -tp[1],
              tp[0],
          ),
          enumerate(D),
      )
  )  # 相当于-d处0时出发 (-d, index)
  
  D.sort()
  STX.sort(key=lambda tp: tp[0])  # sort by -d
  # O(n) zhuqufa
  ans = [-1 for i in range(len(D))]
  level = 0
  while (1 << level) < len(D):  # leaves cnt >= len(D)
      level += 1
  tree = [(0, 0) for i in range((1 << (level + 1)) - 1)]
  Dstart = (1 << level) - 1
  Dend = (1 << level) - 1 + len(D)
  # print(Dstart, Dend, len(tree), level)
  for i in range(Dstart, Dend):
      ii = i
      i -= Dstart
      tree[ii] = [D[i][0], D[i][0], -1, D[i][1]]
  for i in range(Dend, len(tree)):
      tree[i] = [D[-1][0], D[-1][0], 0]  # [3] = 0,自动忽略
  for i in range(Dstart - 1, 0 - 1, -1):
      l = i * 2 + 1
      r = i * 2 + 2
      tree[i] = [tree[l][0], tree[r][1], min(tree[l][2], tree[r][2])]
  
  
  def search(l, r, d, i):  # [l,r] terminate at d
      if tree[i][2] >= 0:
          return  # done
      if r < tree[i][0]:
          return
      if l > tree[i][1]:
          return
      if i >= Dend:
          return
      if i >= Dstart:
          tree[i][2] = d
          return
      lc = i * 2 + 1
      rc = i * 2 + 2
      search(l, r, d, lc)
      search(l, r, d, rc)
      tree[i][2] = min(tree[lc][2], tree[rc][2])
  
  
  # print(tree[:Dstart])
  # print(tree[Dstart:Dend])
  # print(tree[Dend:])
  for s, t, x in STX:
      t -= 1
      l = x - t
      r = x - s
      search(l, r, x, 0)
  #     print('\n',l,r,x, [s,t,x])
  #     print(tree[:Dstart])
  #     print(tree[Dstart:Dend])
  #     print(tree[Dend:])
  for a, b, d, i in tree[Dstart:Dend]:
      ans[i] = d
  for x in ans:
      print(x)
  
problem_description: Statement
  
  There is an infinitely long street that runs west to east, which we consider
  as a number line.
  
  There are N roadworks scheduled on this street. The i-th roadwork blocks the
  point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.
  
  Q people are standing at coordinate 0. The i-th person will start the
  coordinate 0 at time D_i, continue to walk with speed 1 in the positive
  direction and stop walking when reaching a blocked point.
  
  Find the distance each of the Q people will walk.
samples: [{"input": "4 6\n    1 3 2\n    7 13 10\n    18 20 13\n    3 4 2\n    0\n    1\n    2\n    3\n    5\n    8", "output": "2\n    2\n    10\n    -1\n    13\n    -1\n    \n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate\n2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at\ntime 3. The first roadwork has ended, but the fourth roadwork has begun, so\nthis person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they\nwalk forever. The output for these cases is -1."}]