#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long sn, x, y;
  long long p[4001] = {0};
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i <= 4000; i++) p[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> sn >> x >> y;
      p[sn] += x * y;
    }
    int flag = 0;
    for (int i = 1; i <= 4000; i++) {
      if (p[i] >= 1000000) {
        cout << i << endl;
        flag++;
      }
    }
    if (flag == 0) cout << "NA" << endl;
  }
}
