#include <bits/stdc++.h>
int main() {
  int n, i, j, con = 0, ans[111111] = {0}, bangou[4000] = {0},
               tanka[1111111] = {0}, kazu[100000] = {0};
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d %d %d", &bangou[i], &tanka[i], &kazu[i]);
      ans[i] = tanka[i] * kazu[i];
      for (j = 0; j < i; j++) {
        if (ans[i] == ans[j]) {
          ans[j] = ans[i] + ans[j];
          ans[i] = 0;
        }
      }
    }
    for (j = 0; j < n; j++) {
      if (ans[j] >= 1000000) {
        printf("%d\n", bangou[j]);
        con++;
      }
    }
    if (ans[i] == 0) {
      printf("NA\n");
    }
  }
  return 0;
}
