#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int check;
  while (cin >> n) {
    if (n == 0) break;
    check = 0;
    long long num[4001] = {0};
    long long emp, cost, count;
    for (int i = (0); i < (n); i++) {
      cin >> emp >> cost >> count;
      num[emp] += cost * count;
    }
    for (int i = (0); i < (4001); i++) {
      if (num[i] >= 1000000) {
        cout << i << endl;
        check++;
      }
    }
    if (check == 0) cout << "NA" << endl;
  }
}
