#include <bits/stdc++.h>
using namespace std;
int main() {
  int em[40000];
  int num, i, id, p, q, flag;
  cin >> num;
  while (num != 0) {
    flag = 0;
    for (i = 0; i < 40000; i++) {
      em[i] = 0;
    }
    for (i = 0; i <= num - 1; i++) {
      cin >> id >> p >> q;
      em[id] += p * q;
    }
    for (i = 0; i < 40000; i++) {
      if (em[i] >= 1000000) {
        cout << i << "\n";
        flag = 1;
      }
    }
    if (flag != 1) cout << "NA\n";
    cin >> num;
  }
  return 0;
}
