#include <bits/stdc++.h>
using namespace std;
struct date {
  long long int tanka;
  long long int uriage;
  long long int sum;
};
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    date a[5000] = {0};
    int number;
    for (int i = 0; i < n; i++) {
      cin >> number;
      cin >> a[number].tanka >> a[number].uriage;
      a[number].sum += a[number].tanka * a[number].uriage;
    }
    bool flg = 0;
    for (int i = 1; i <= 4000; i++) {
      if (a[i].sum >= 1000000) cout << i << endl, flg = 1;
    }
    if (!flg) cout << "NA" << endl;
  }
  return 0;
}
