#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    unsigned long long a[5000] = {0}, c = 0, p, o, u;
    for (int i = 0; i < 5000; i++) cout << a[i];
    for (int i = 0; i < n; i++) {
      cin >> p >> o >> u;
      a[p] += o * u;
      if (a[p] >= 1000000) {
        cout << p << endl;
        c++;
      }
    }
    if (!c) cout << "NA" << endl;
  }
  return 0;
}
