#include <bits/stdc++.h>
int num[4000], f;
long price[4000];
int main(void) {
  int i, j, n, x, y, z;
  while (scanf("%d", &n), n != 0) {
    f = 0;
    for (i = 0; i < 4000; i++) price[i] = 0;
    i = 0;
    for (; n--;) {
      scanf("%d %d %d", &x, &y, &z);
      for (j = 0; j < i; j++)
        if (num[j] == x) break;
      if (j == i) num[j] = x, i++;
      price[j] += y * z;
    }
    for (j = 0; j < i; j++)
      if (price[j] >= 1000000) printf("%d\n", num[j]), f = 1;
    if (!f) puts("NA");
  }
  return 0;
}
