#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  while (cin >> num, num) {
    vector<int> order;
    long data[4000] = {0};
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      for (int i = 0; i < order.size(); i++) {
        if (order[i] == id) {
          break;
        }
        if (i == order.size() - 1) {
          order.push_back(id);
        }
      }
      if (order.size() == 0) {
        order.push_back(id);
      }
      data[id] += price * sold_num;
    }
    int count = 0;
    for (int i = 0; i < order.size(); i++) {
      if (data[order[i]] >= 1000000) {
        cout << order[i] << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}
