#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool flag = 0;
    long long int result[4001] = {};
    for (int i = 0, str, sale, num, ans = 0; i < n; i++) {
      cin >> str >> sale >> num;
      result[str] += sale * num;
      if (result[str] >= 1000000) {
        cout << str << endl;
        result[str] = -5000000;
        flag = 1;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
}
