#include <bits/stdc++.h>
using namespace std;
struct DATA {
  int id;
  int sales;
};
int main() {
  while (1) {
    int n;
    cin >> n;
    if (!n) break;
    list<struct DATA> sales_list;
    for (int i = 0; i < n; i++) {
      int id, p, q;
      cin >> id >> p >> q;
      int flag = 0;
      for (list<struct DATA>::iterator i = sales_list.begin();
           i != sales_list.end(); i++) {
        if (i->id == id) {
          i->sales += p * q;
          flag = 1;
          break;
        }
      }
      if (!flag) {
        struct DATA d;
        d.id = id;
        d.sales = p * q;
        sales_list.push_back(d);
      }
    }
    int flag = 0;
    for (list<struct DATA>::iterator i = sales_list.begin();
         i != sales_list.end(); i++) {
      if (i->sales >= 1000000) {
        cout << i->id << endl;
        flag = 1;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
