#include <bits/stdc++.h>
using namespace std;
static inline int in() {
  int x;
  scanf("%d", &x);
  return (x);
}
static inline long long int lin() {
  long long int x;
  scanf("lld", &x);
  return (x);
}
int main() {
  list<int> staffList;
  map<int, long long int> saleResult;
  int n;
  int staffNum;
  long long int unitPrice;
  long long int quantity;
  while (1) {
    n = in();
    if (n == 0) break;
    staffList.clear();
    saleResult.clear();
    for (int i = (0), i_ = (n); i < i_; ++i) {
      staffNum = in();
      unitPrice = lin();
      quantity = lin();
      staffList.push_back(staffNum);
      saleResult[staffNum] += unitPrice * quantity;
    }
    bool flag = false;
    for (list<int>::iterator it = staffList.begin(); it != staffList.end();
         it++) {
      if (saleResult[*it] >= 1000000) {
        printf("%d\n", *it);
        saleResult[*it] = 0;
        flag = true;
      }
    }
    if (!flag) {
      cout << "NA" << endl;
    }
  }
  return (0);
}
