#include <bits/stdc++.h>
int main(void) {
  int n = 1;
  int flg = 0;
  int bangou[4001] = {0};
  int tanka[4001] = {0};
  int kosuu[4001] = {0};
  int goukei[4001] = {0};
  int ccc = 0;
  int i = 0, j = 0;
  while (n != 0) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    } else {
      for (i = 1; i <= n; i++) {
        ccc++;
        scanf("%d %d %d", &bangou[ccc], &tanka[ccc], &kosuu[ccc]);
        goukei[ccc] = tanka[ccc] * kosuu[ccc];
        for (j = 1; j < ccc; j++) {
          if (bangou[j] == bangou[ccc]) {
            goukei[j] += goukei[ccc];
            ccc--;
          }
        }
      }
      for (i = 1; i <= ccc; i++) {
        if (goukei[i] >= 1000000) {
          printf("%d\n", bangou[i]);
          flg = 1;
        }
      }
      if (flg == 0) {
        printf("NA\n");
      }
      flg = 0;
      ccc = 0;
    }
  }
  return 0;
}
