#include <bits/stdc++.h>
using namespace std;
int n;
int meibo[4001];
struct kanri {
  int number;
  int sum;
} syain[4001];
void shoki();
int main() {
  while (true) {
    scanf("%d", &n);
    if (n == 0) break;
    shoki();
    int num = 0;
    int kari;
    for (int i = 0; i < n; i++) {
      scanf("%d", &kari);
      bool flag = false;
      for (int j = 0; j < num; j++) {
        if (syain[j].number == kari) {
          int kari1, kari2;
          scanf("%d%d", &kari1, &kari2);
          syain[j].sum += kari1 * kari2;
          flag = true;
          break;
        }
      }
      if (!flag) {
        int kari1, kari2;
        syain[num].number = kari;
        scanf("%d%d", &kari1, &kari2);
        syain[num].sum += kari1 * kari2;
        num++;
      }
    }
    bool flag2 = false;
    for (int i = 0; i < n; i++) {
      if (syain[i].sum >= 1000000) {
        printf("%d\n", syain[i].number);
        flag2 = true;
      }
    }
    if (!flag2) {
      printf("NA\n");
    }
  }
  return 0;
}
void shoki() {
  for (int i = 0; i < 4001; i++) {
    syain[i].number = 0;
    syain[i].sum = 0;
  }
}
