#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, int> e;
    vector<int> num;
    int cntnum[4000] = {0};
    for (int i = 1; i <= 4000; i++) {
      e[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int tmp[3];
      cin >> tmp[0] >> tmp[1] >> tmp[2];
      e[tmp[0]] += tmp[1] * tmp[2];
      if (cntnum[tmp[0]] == 0) {
        num.push_back(tmp[0]);
        cntnum[tmp[0]]++;
      }
    }
    int cnt = 0;
    for (int i = 0; i < num.size(); i++) {
      if (e[num[i]] >= 1000000) {
        cout << num[i] << endl;
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << "NA" << endl;
    }
  }
}
