#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    long long ta[5000] = {0};
    long long x[5000] = {0};
    long long cnt = 0, a, b, c;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      ta[a] += b * c;
      bool f = 1;
      for (int j = 0; j < i; j++)
        if (x[j] == a) f = 0;
      if (f) x[cnt++] = a;
    }
    bool f = 1;
    for (int i = 0; i < n - 1; i++) {
      if (ta[x[i]] >= 1000000) {
        cout << x[i] << endl;
        f = 0;
      }
    }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
