#include <bits/stdc++.h>
using namespace std;
struct Saler {
  int Number;
  int Saled;
};
int main() {
  struct Saler* sl;
  int n, a, b, c, i;
  bool isFound;
loop:
  scanf("%d\n", &n);
  if (n == 0) goto end_scope;
  sl = (struct Saler*)malloc(sizeof(struct Saler) * n);
  memset(sl, 0, sizeof(struct Saler) * n);
  for (int j = 0; j < n; j++) {
    scanf("%d %d %d\n", &a, &b, &c);
    for (i = 0; i < n; i++) {
      if (sl[i].Number == 0) {
        sl[i].Number = a;
        sl[i].Saled = b * c;
        break;
      } else if (sl[i].Number == a) {
        sl[i].Saled += b * c;
        break;
      }
    }
  }
  isFound = false;
  for (int j = 0; j < n; j++) {
    if (sl[j].Saled >= 1000000) {
      cout << sl[j].Number << endl;
      isFound = true;
    }
  }
  !isFound && (cout << "NA" << endl);
  free(sl);
  goto loop;
end_scope:
  return 0;
}
