#include <bits/stdc++.h>
using namespace std;
class MAN {
 public:
  unsigned int uriage;
  int number;
};
int main(int argc, char const* argv[]) {
  MAN* person;
  int n;
  bool flag;
  while (cin >> n && n != 0) {
    person = new MAN[n];
    for (int i = 0; i < n; i++) {
      int target;
      int a, b;
      cin >> target >> a >> b;
      int j;
      for (j = 0; j < i; j++) {
        if (person[j].number == target) {
          person[j].uriage += a * b;
          break;
        }
      }
      if (j == i) {
        person[i].number = target;
        person[i].uriage = a * b;
      }
    }
    flag = false;
    for (int i = 0; i < n; i++) {
      if (person[i].uriage >= 1000000) {
        cout << person[i].number << endl;
        flag = true;
      }
    }
    if (flag == false) cout << "NA" << endl;
    delete[] person;
  }
  return 0;
}
