#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int x[4001] = {0};
  int m[4001] = {0};
  while (1) {
    int e, p, q, count = 0;
    cin >> n;
    if (n == 0) break;
    for (int i = 1; i <= n; i++) {
      cin >> e >> p >> q;
      x[e] += p * q;
      if (x[e] >= 1000000) {
        if (m[e] == 0) {
          cout << e << endl;
          count++;
          m[e]++;
        }
      }
    }
    if (count < 0) cout << "NA" << endl;
  }
  return 0;
}
