#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (cin >> n, n) {
    map<int, int> name;
    long long int list[4001] = {0};
    int a, b, c, j = 0;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      name[j] = a, j++;
      if (list[a] < 1000000) list[a] += b * c;
    }
    bool check = true;
    for (int i = 0; i < 4000; i++)
      if (list[name[i]] >= 1000000)
        cout << (name[i]) << endl, check = false, list[name[i]] = 0;
    if (check) cout << "NA" << endl;
  }
  return 0;
}
