#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b;
  int a, num[4001], tanka, uriage, jun[4001];
  bool judge, nnnn;
  while (cin >> n) {
    if (n == 0) break;
    judge = true;
    for (int i = 0; i < 4001; i++) {
      num[i] = 0;
    }
    for (int i = 0, b = 0; i < n; i++) {
      nnnn = true;
      cin >> a >> tanka >> uriage;
      num[a] += tanka * uriage;
      for (int j = 0; j < i; j++) {
        if (jun[j] == a) {
          nnnn = false;
          break;
        }
      }
      if (nnnn) {
        jun[b] = a;
        b++;
      } else
        jun[b] = 0;
    }
    for (a = 0; jun[a] != 0; a++) {
      if (num[jun[a]] >= 1000000) {
        cout << jun[a] << endl;
        judge = false;
      }
    }
    if (judge) cout << "NA" << endl;
  }
  return 0;
}
