#include <bits/stdc++.h>
using namespace std;
long long data[4010];
bool out[4010];
int main() {
  int i, j, k, n;
  int id;
  long long a, b;
  while (scanf("%d", &n)) {
    if (n == 0) break;
    bool f = false;
    memset(out, true, sizeof(out));
    memset(data, 0, sizeof(data));
    while (n--) {
      scanf("%d %lld %lld", &id, &a, &b);
      data[id] += a * b;
      if (data[id] >= 1000000LL && out[id]) {
        out[id] = false;
        printf("%d\n", id);
        f = true;
      }
    }
    if (f) puts("NA");
  }
  return 0;
}
