#include <bits/stdc++.h>
using namespace std;
int sale[4001];
int main() {
  int p;
  while (cin >> p, p) {
    for (int i = 0; i < 4001; i++) sale[i] = 0;
    int id, price, num, result = 0;
    for (int i = 0; i < p; i++) {
      cin >> id >> price >> num;
      sale[id] += price * num;
    }
    for (int i = 0; i < 4001; i++) {
      if (1000000 <= sale[i]) {
        cout << i << endl;
        result++;
      }
    }
    if (result == 0) cout << "NA" << endl;
  }
}
