#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int num[4000];
  bool appear[4001];
  int howmany;
  int number;
  long long int in_price;
  long long int in_sales;
  long long int price[4001];
  long long int sales[4001];
  while (1) {
    for (int i = 0; i < 4001; i++) {
      if (i < 4001) num[i] = 0;
      appear[i] = false;
      price[i] = 0;
      sales[i] = 0;
    }
    howmany = 0;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> number;
      cin >> in_price;
      cin >> in_sales;
      price[number] += in_price;
      sales[number] += in_sales;
      if (!appear[number]) num[i] = number;
      appear[number] = true;
    }
    for (int i = 0; i < n; i++) {
      if (num[i] != 0) {
        if (price[num[i]] * sales[num[i]] >= 1000000) {
          cout << num[i] << endl;
          howmany++;
        }
      }
    }
    if (howmany == 0) cout << "NA" << endl;
  }
  return 0;
}
