#include <bits/stdc++.h>
int main() {
  int i, n;
  int mn, su, x;
  while (1) {
    int co[40000] = {0};
    int sum[40000] = {0};
    int num[40000] = {0};
    int mnx[40000] = {0};
    int sux[40000] = {0};
    scanf("%d", &n);
    if (n != 0) {
      for (i = 0; i < n; i++) {
        scanf("%d", &x);
        num[x] = x;
        scanf("%d %d", &mn, &su);
        mnx[x] += mn;
        sux[x] += su;
        sum[x] = mnx[x] * sux[x];
        if (mn <= 1000000 && sux[x] <= 100000 && sum[x] >= 1000000) {
          co[x] = 1;
        }
      }
      for (i = 1; i < 4001; i++) {
        if (co[i] == 1) {
          printf("%d\n", num[i]);
        } else {
          co[n + 1]++;
        }
      }
      if (co[n + 1] == 4000) {
        puts("NA");
      }
    } else {
      return 0;
    }
  }
}
