#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, flag, f[4005];
  map<int, long long int> m;
  while (cin >> n, n) {
    for (int i = 0; i < 4005; i++) f[i] = 0;
    m.clear();
    flag = 0;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (!f[a]) {
        if ((long long int)b * (long long int)c >= 1000000ll) f[a] = 1;
        m[a] += (long long int)b * (long long int)c;
        if (m[a] >= 1000000ll) f[a] = 1;
      }
    }
    for (int i = 0; i < 4005; i++) {
      if (f[i]) {
        cout << i << endl;
        flag = 1;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
