#include <bits/stdc++.h>
int main(void) {
  int c, hc = 0;
  while (scanf("%d", &c)) {
    int i, f = 0, ov[4000][2], hc = 0, ka = 0;
    if (c == 0) break;
    for (i = 0; c > i; i++) {
      int a, b, k, num, al = 0;
      scanf("%d%d%d", &num, &a, &b);
      for (k = 0; hc > k; k++) {
        if (ov[k][0] == num) {
          ov[k][1] += a * b;
          al = 1;
        }
      }
      if (al == 0) {
        ov[hc][0] = num;
        ov[hc][1] = a * b;
        hc++;
      }
    }
    for (ka = 0; hc > ka; ka++) {
      if (ov[ka][1] >= 1000000) {
        printf("%d\n", ov[ka][0]);
        f = 1;
      }
    }
    if (f == 0) printf("NA\n");
    f = 0;
    hc = 0;
  }
  return 0;
}
