#include <bits/stdc++.h>
using namespace std;
struct R {
  int num;
  int su;
  int k;
};
int main() {
  int N, M;
  while (1) {
    struct R n[4001];
    cin >> N;
    if (N == 0) break;
    for (int i = 0; i <= 4000; i++) n[i].su = 0;
    for (int i = 1; i <= N; i++) {
      int r, q, nu;
      cin >> nu;
      n[nu].num = nu;
      cin >> r >> q;
      if (n[nu].su == 0) {
        n[nu].k = i;
      }
      n[nu].su += r * q;
    }
    bool f = false;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < 4001; j++)
        if (n[j].k == i && n[j].su >= 1000000) {
          cout << n[j].num << endl;
          f = true;
        }
    if (f == false) cout << "NA" << endl;
  }
  return 0;
}
