#include<iostream>
#include<map>
using namespace std;

int main() {
  int num = 0;
  while (cin >> num, num) {
    int data[4000] = { 0 };
    int count = 0;
    for (int i = 0; i < num; i++) {
      int id, price, sold_num;
      cin >> id >> price >> sold_num;
      data[id] += price*sold_num;
    }
    for (int i = 0; i < 4000; i++) {
      if (data[i] >= 1000000) {
        cout << i << endl;
        count++;
      }
    }
    if (count == 0) {
      cout << "NA" << endl;
    }
  }
}