#include <bits/stdc++.h>
int main(void) {
  int n, i, j, k = 0, x[4001], y, z;
  int a[4001] = {0};
  long long b[4001] = {0};
  int flag[4001] = {0};
  for (;;) {
    k = 0;
    for (j = 0; j < n; j++) {
      a[j] = 0;
      b[j] = 0;
      flag[j] = 0;
      x[j] = 0;
    }
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x[i], &y, &z);
      if (flag[i] == 1)
        ;
      else {
        if (a[i] != 0)
          b[i] = b[i] + y * z;
        else {
          a[i] = x[i];
          b[i] = y * z;
        }
      }
      if (b[i] >= 1000000) {
        printf("%d\n", a[i]);
        flag[i]++;
        k++;
      }
    }
    if (k == 0) printf("NA\n");
  }
  return 0;
}
