#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool num[4001] = {false}, flag = false;
    int sum[4001] = {0}, m, ex, a;
    for (int i = 0; i < n; i++) {
      cin >> m >> ex >> a;
      sum[m] += ex * a;
      if (1000000 <= sum[m]) {
        num[m] = true;
        flag = true;
      }
    }
    if (flag) {
      for (int i = 1; i <= 4000; i++) {
        if (num[i]) {
          cout << i << endl;
        }
      }
    } else {
      cout << "NA" << endl;
    }
  }
  return (0);
}
