#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (cin >> n && n != 0) {
    set<int> T;
    bool exist = false;
    for (int i = 0; i < n; i++) {
      int no, price, items;
      cin >> no >> price >> items;
      if (price <= 1000000 && items <= 100000) {
        long long profit = (long long)price * items;
        if (T.find(no) == T.end() && profit >= 1000000L) {
          exist = true;
          cout << no << endl;
          T.insert(no);
        }
      }
    }
    if (exist == false) cout << "NA" << endl;
  }
  return 0;
}
