#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    unordered_map<int, int> pos;
    vector<pair<int, long long>> res(4001);
    for (int i = 1; i <= n; ++i) {
      int no, price, quantity;
      cin >> no >> price >> quantity;
      if (!pos[no]) {
        pos[no] = i;
        res[pos[no]].first = no;
      }
      res[pos[no]].second += price * quantity;
    }
    bool NA = true;
    for (int i = 0; i < (int)res.size(); ++i) {
      if (res[i].second >= 1000000) {
        cout << res[i].first << endl;
        NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}
