#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    long long int tmp[4001] = {0};
    vector<int> no;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      no.push_back(a);
      tmp[a] += b * c;
    }
    int co = 0;
    for (int i = 0; i < n; i++) {
      if (tmp[no[i]] >= 1000000) {
        int han = 0;
        for (int j = 0; j < i; j++) {
          if (no[i] == no[j]) {
            han = 1;
            break;
          }
        }
        if (han) continue;
        co++;
        cout << no[i] << endl;
      }
    }
    if (!co) cout << "NA" << endl;
  }
}
