#include <bits/stdc++.h>
int main(int argc, char* argv[]) {
  int i;
  for (;;) {
    int d[4000 + 1] = {0};
    int c = 0;
    int n;
    scanf("%d", &n);
    if (!n) break;
    for (i = 0; i < n; ++i) {
      int no, price, num;
      scanf("%d%d%d", &no, &price, &num);
      d[no] += price * num;
    }
    for (i = 1; i <= 4000; ++i) {
      if (d[i] >= 1000000) {
        printf("%d\n", i);
        ++c;
      }
    }
    if (c) {
      puts("NA");
    }
  }
  return (0);
}
