#include <bits/stdc++.h>
struct KOUZOUTAI0100 {
  int no;
  long long int tanka;
  long long int kazu;
  long long int sum;
};
int linearSearch(struct KOUZOUTAI0100 array[], int n, int key);
int main() {
  int i;
  int n, m = 0;
  int count;
  int isExist;
  struct KOUZOUTAI0100 data[4000];
  struct KOUZOUTAI0100 temp;
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 0; i < m; i++) {
      data[i].no = 0;
      data[i].sum = 0;
    }
    m = 0;
    count = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &temp.no, &temp.tanka, &temp.kazu);
      isExist = linearSearch(data, m, temp.no);
      if (isExist != -1) {
        data[isExist].sum += temp.tanka * temp.kazu;
      } else {
        data[m] = temp;
        data[m].sum += data[m].tanka * data[m].kazu;
        m++;
      }
    }
    for (i = 0; i < m; i++) {
      if (data[i].sum >= 1000000) {
        printf("%d\n", data[i].no);
        count++;
      }
    }
    if (count == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
int linearSearch(struct KOUZOUTAI0100 array[], int n, int key) {
  int i;
  int ret = -1;
  for (i = 0; i < n; i++) {
    if (array[i].no == key) {
      ret = i;
      break;
    }
  }
  return ret;
}
