#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    scanf("%d", &n);
    if (n == 0) break;
    vector<int> order;
    map<int, int> sale;
    for (int i = 0; i < n; ++i) {
      int no, value, num;
      scanf("%d %d %d", &no, &value, &num);
      if (sale.count(no) == 0) {
        sale.insert(make_pair(no, 0));
        order.push_back(no);
      }
      int t = (int)value * num;
      sale[no] += t;
    }
    bool any = false;
    for (int i = 0; i < order.size(); ++i) {
      if (sale[order[i]] >= 1000000) {
        printf("%d\n", order[i]);
        any = true;
      }
    }
    if (!any) printf("NA\n");
  }
  return 0;
}
