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