#include <bits/stdc++.h>
using namespace std;
long long int shine[4040];
int main() {
  long long int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (long long int i = 0; i < ((long long int)(4040)); i++) shine[i] = 0;
    for (long long int i = 0; i < ((long long int)(n)); i++) {
      long long int a1, a2, a3;
      cin >> a1 >> a2 >> a3;
      shine[a1] += a2 * a3;
    }
    bool ita = false;
    for (long long int i = 0; i < ((long long int)(4040)); i++) {
      if (shine[i] >= 1000000) {
        cout << i << endl;
        ita = true;
      }
    }
    if (!ita) puts("NA");
  }
  return 0;
}
