#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    long n;
    map<int, long long> mp;
    scanf(" %ld", &n);
    if (n == 0) break;
    for (long i = 0; i < n; ++i) {
      int num;
      long t, u;
      scanf(" %d %ld %ld", &num, &t, &u);
      if (mp.find(num) != mp.end())
        mp[num] += t * u;
      else
        mp[num] = t * u;
    }
    int count = 0;
    for (map<int, long long>::iterator itr = mp.begin(); itr != mp.end();
         ++itr) {
      if (itr->second >= 1000000) {
        printf("%d\n", itr->first);
        ++count;
      }
    }
    if (count == 0) printf("NA\n");
  }
}
