#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i, p, q;
  while (cin >> n && n) {
    bool isExist = false;
    map<int, long long int> emp;
    for (int l = 0; l < (n); ++l) {
      cin >> i >> p >> q;
      if (emp[i] != -1) {
        emp[i] += p * q;
        if (emp[i] >= 1000000) {
          cout << i << endl;
          emp[i] = -1;
          isExist = true;
        }
      }
    }
    if (!isExist) cout << "NA" << endl;
  }
}
