#include <iostream>
using namespace std;

int main() {
  int n,ID,price,quantity,sales[4001] = {0},check;
  while(cin >> n) {
    int sales[4001] = {0};
    if(n == 0) break;
    for(int i=0;i<n;i++) {
      cin >> ID >> price >> quantity;
      sales[ID] += price * quantity;
    }
    check = 0;
    for(int i=1;i<4001;i++) {
      if(sales[i] >= 1000000) {
        cout << i << endl;
        check = 1;
      }
    }
    if(check == 0)
      cout << "NA" << endl;
  }
}