/*
   ??\????????????????????°?????????????????\???????????????????????????
 */

#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long int LLI;

int n;
LLI total[1000000];
bool used[1000000];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    fill(total, total+n+10, 0);
    fill(used, used+n+10, false);

    bool found = false;
    while (n--) {
      int id;
      LLI p, q;

      scanf("%d%lld%lld", &id, &p, &q);
      total[id] += p*q;
      if (total[id] >= 1000000 && !used[id]) {
        found = true;
        used[id] = true;
        printf("%d\n", id);
      }
    }

    if (!found) puts("NA");
  }
}