def main

  while (n = gets.to_i) != 0
    arr = array
    n.times do
      data = gets.split(" ").map(&:to_i)
      arr[data[0]][1] += data[1] * data[2]
    end
    arr.select!{|item|item[1] >= 10 ** 6}
    if arr.length == 0
      puts "NA"
    else
      puts arr.collect{|item|item[0]}
    end
  end
  
end
def array
  arr = Array.new(4000){|i|[i + 1, 0]}
  def arr.[]=(n, other)
    super(n - 1, other)
  end

  def arr.[](n)
    super(n - 1)
  end

  return arr
end

main