#include <bits/stdc++.h>
using namespace std;
void shoki();
vector<long long> num(4001, 0);
int n, ban, tanka, kazu, i, j;
int main() {
  bool y = false;
  for (j = 0; j < 50; j++) {
    cin >> n;
    if (n == 0) {
      break;
    }
    int count = 0;
    for (i = 0; i < n; i++) {
      cin >> ban >> tanka >> kazu;
      num[ban] += tanka * kazu;
    }
    for (int k = 0; k < 4001; k++) {
      if (num[k] == 0) {
        continue;
      }
      if (num[k] >= 1000000) {
        y = true;
        cout << k << endl;
      }
    }
    if (y == false) {
      cout << "NA" << endl;
    }
    y = false;
    shoki();
  }
  return 0;
}
void shoki() {
  for (int i = 0; i < 4000; i++) {
    num[i] = 0;
  }
}
