#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    map<int, int> sum;
    for (int i = 0; i < n; ++i) {
      int no, price, quantity;
      cin >> no >> price >> quantity;
      sum[no] += price * quantity;
    }
    bool NA = true;
    map<int, int>::iterator it;
    for (it = sum.begin(); it != sum.end(); ++it) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        NA = false;
      }
    }
    if (NA) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
