#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n = 1, num, tanka, suryo;
  long long sum[4001] = {0};
  int jyun[100000000] = {0};
  bool w[4001] = {false};
  bool na = true;
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> num >> tanka >> suryo;
      jyun[i] = num;
      sum[num] += tanka * suryo;
    }
    for (int i = 0; i <= 100000000; i++) {
      if (sum[jyun[i]] >= 1000000) {
        if (!w[jyun[i]]) {
          cout << jyun[i] << endl;
          w[jyun[i]] = true;
        }
        na = false;
      }
      sum[i] = 0;
      jyun[i] = 0;
    }
    if (na) cout << "NA" << endl;
    na = true;
    for (int i = 0; i <= 4000; i++) {
      w[i] = false;
    }
  }
}
