#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, number, money, sum;
  int data[4001] = {0}, dataF[4001] = {0};
  queue<int> ok;
  while (1) {
    for (int i = 0; i < 4000; i++) data[i] = 0, dataF[i] = 0;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> number >> money >> sum;
      data[number] += money * sum;
      if (data[number] >= 1000000 && dataF[number] == 0) {
        dataF[number] = 1;
        ok.push(number);
      }
    }
    if (ok.empty()) {
      cout << "NA" << endl;
    } else {
      while (!ok.empty()) {
        cout << ok.front() << endl;
        ok.pop();
      }
    }
  }
  return 0;
}
