require 'set'

nn, qq = gets.split.map(&:to_i)
events = []
temp = []

def max(a, b)
  a > b ? a : b
end

t = 0
nn.times do
  temp = gets.split.map(&:to_i)
  next if (t = temp[1] - temp[2]) <= 0

  events.push(
    (max((temp[0] - temp[2]), 0) << 32) +
    (2 << 30) +
    temp[2]
  )
  events.push(
    (t << 32) +
    (1 << 30) +
    temp[2]
  )
end

1.step(qq, 1) do |i|
  events.push(
    (gets.to_i << 32) +
    3 << 30 +
    i
  )
end

# '30bit-2bit-30bit'
#  ソートするための区間 - タイプ - indexなどの情報
mask_2 = ((1 << 2)  - 1) << 30
mask_3 = ((1 << 30) - 1)

events.sort!

ss = Set.new
ans = []
events.each do |event|
  case (event & mask_2) >> 30
  when 2
    ss.add(event & mask_3)
  when 1
    ss.delete(event & mask_3)
  else
    ans[(event & mask_3)] = ss.min || -1
  end
end

puts ans[1..-1]
