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