#include <bits/stdc++.h>
long long int t[4000];
int main() {
  int a;
  while (scanf("%d", &a), a) {
    for (int i = 0; i < a; i++) {
      int b, c, d;
      scanf("%d%d%d", &b, &c, &d);
      t[b - 1] += (long long)c * d;
    }
    bool ok = false;
    for (int i = 0; i < 4000; i++) {
      if (t[i] >= 1000000) {
        printf("%d\n", i + 1);
        ok = true;
      }
      t[i] = 0;
    }
    if (!ok) printf("NA\n");
  }
}
