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