#include <bits/stdc++.h>
using namespace std;
struct data {
  int id;
  long long price;
  long long amount;
  long long rate;
};
int main() {
  int n = 0;
  while (1) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    vector<struct data> data(n);
    int c = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d %l %l", &data[i].id, &data[i].price, &data[i].amount);
      data[i].rate = data[i].price * data[i].amount;
    }
    vector<struct data> res(n);
    for (int i = 0; i < n; i++) {
      res[i].id = 0;
      res[i].rate = 0;
    }
    for (int i = 0; i < n; i++) {
      int find = 0;
      for (int j = 0; j < i; j++) {
        if (data[i].id == res[j].id) {
          res[j].rate += data[i].rate;
          find = 1;
          break;
        }
      }
      if (find == 0) {
        res[i].id = data[i].id;
        res[i].rate = data[i].rate;
      }
    }
    for (int i = 0; i < n; i++) {
      if (res[i].id != 0 && res[i].rate >= 1000000) {
        cout << data[i].id << "\n";
        c++;
      }
    }
    if (c == 0) {
      cout << "NA\n";
    }
  }
  return 0;
}
