#include <bits/stdc++.h>
using namespace std;
struct data {
  int ID;
  long total;
  int order;
  data() {
    ID = -1;
    total = 0;
    order = 100000;
  }
  data(int n) {
    ID = n;
    total = 0;
    order = 100000;
  }
  bool operator<(const data d) const { return order < d.order; }
};
int main() {
  int n;
  while (cin >> n, n) {
    int ID, price, sale;
    data table[4096];
    bool flag = false;
    int order_count = 0;
    for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
      table[i] = data(i);
    }
    for (int i = 0; i < n; i++) {
      cin >> ID >> price >> sale;
      if (table[ID].order != 100000) {
        table[ID].order = order_count;
        order_count++;
      }
      table[ID].total += price * sale;
    }
    sort(table, table + 4096);
    for (int i = 0; i < 4096; i++) {
      if (table[i].total >= 1000000) {
        cout << table[i].ID << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
