#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (true) {
    int cnt = 0;
    long long int s[4002] = {0}, gs[4002] = {0};
    cin >> n;
    if (!n) break;
    long long int t, cost;
    int num;
    for (int i = 0; i < n; i++) {
      cin >> num >> t >> cost;
      s[num] += t * cost;
      gs[i] = num;
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (gs[i] == gs[j] && i < j) {
          s[gs[i]] += s[j];
          gs[j] = 4001;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (s[gs[i]] >= 1000000) {
        cout << gs[i] << endl;
        cnt++;
      }
    }
    if (!cnt) cout << "NA" << endl;
  }
  return 0;
}
