#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n, n) {
    map<long long, long long> mp;
    for (int i = 0; i < n; i++) {
      long long e, p, q;
      cin >> e >> p >> q;
      mp[e] += p * q;
    }
    bool flag = false;
    for (auto i : mp) {
      if (i.second >= 1000000) {
        flag = true;
        cout << i.first << endl;
      }
    }
    if (!flag) puts("NA");
  }
}
