#include <bits/stdc++.h>
using namespace std;
struct wor {
  int mon;
  int fla;
};
int main() {
  wor id[100000];
  int ta, tan, i, s, p, doc[100], j;
  while (cin >> ta && ta != 0) {
    int f = 0;
    for (j = 0; j < ta; j++) {
      cin >> i >> s >> p;
      doc[j] = i;
      if (id[i].fla == 2) {
        id[i].mon = id[i].mon + (s * p);
      } else {
        id[i].mon = s * p;
        id[i].fla = 2;
      }
    }
    for (j = 0; j < ta; j++) {
      if (id[doc[j]].fla == 3) {
        continue;
      } else {
        if (id[doc[j]].mon >= 1000000) {
          cout << doc[j] << endl;
          id[doc[j]].fla = 3;
          f = 1;
        }
      }
    }
    for (j = 0; j < ta; j++) {
      id[doc[j]].fla = 0;
    }
    if (f == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
