#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  vector<long long> data(4000);
  int i;
  int a, b, c;
  int max;
  bool check;
  cin >> i;
  while (i) {
    for (int j = 0; j < 4000; j++) {
      data[j] = 0;
    }
    for (int j = 0; j < i; j++) {
      cin >> a >> b >> c;
      data[a - 1] += b * c;
    }
    check = false;
    for (int j = 0; j < 4000; j++) {
      if (data[j] >= 1000000) {
        printf("%d\n", j + 1);
        check = true;
      }
    }
    if (!check) printf("NA\n");
    cin >> i;
  }
  return 0;
}
