#include <bits/stdc++.h>
using namespace std;
int shineN, eliteN;
int shineI[4000];
long int shineU[4000];
int dataN, num, tanka, suryo;
int i, j;
int main() {
  while (1) {
    cin >> dataN;
    if (dataN == 0) {
      break;
    }
    shineN = 0;
    for (j = 0; j < dataN; j++) {
      cin >> num >> tanka >> suryo;
      num--;
      for (i = 0; i < shineN; i++) {
        if (shineI[i] == num) {
          break;
        }
      }
      if (i == shineN) {
        shineU[num] = 0;
        shineI[shineN] = num;
        shineN++;
      }
      shineU[num] += suryo * tanka;
    }
    eliteN = 0;
    for (j = 0; j < shineN; j++) {
      i = shineI[j];
      if (1000000 <= shineU[i]) {
        cout << i + 1 << endl;
        eliteN++;
      }
    }
    if (eliteN == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
