#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int printed = 0;
    long long int table[4001];
    for (int i = 0; i < 4001; i++) {
      table[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int b, t, k;
      cin >> b >> t >> k;
      if (table[b] < 1000000) {
        table[b] += t * k;
        if (table[b] >= 1000000) {
          cout << b << endl;
          printed = 1;
        }
      }
    }
    if (printed == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
