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