# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=ja
=begin
---SAMPLE INPUT---
4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
1001 1000000 0
1005 1 100000
0
=end

emp_list = {}

loop do
  data_line_count = gets.strip.to_i
  break if data_line_count == 0

  (1..data_line_count).each do
    emp_no, price, amount = gets.strip.split(' ')
    emp_list[emp_no.to_s] ||= 0
    emp_list[emp_no.to_s] += price.to_i * amount.to_i
  end

  emp_list.select {|_, value|
    value >= 1_000_000
  }.tap {|output_list|
    if output_list.empty?
      puts 'NA'
    else
      output_list.each_key {|key| puts key }
    end
  }
  emp_list.clear
end

