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