#include <bits/stdc++.h>
using namespace std;
unsigned long long int a[4001];
int main() {
  int n, num, p, q;
  while (cin >> n, n) {
    int f = 1;
    for (int i = 0; i < 4001; i++) a[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> num >> p >> q;
      a[num] += p * q;
      if (a[num] > 999999) {
        printf("%d\n", num);
        f = 0;
      }
    }
    if (f) cout << "NA" << endl;
  }
  return 0;
}
