#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  int a, b, c, d;
  int num[4001], tan[4001], ans[4001];
  bool flag = false;
  while (1) {
    for (a = 0; a <= 4000; a++) {
      num[a] = 0;
      tan[a] = 0;
      ans[a] = 0;
    }
    flag = false;
    cin >> n;
    if (n == 0) break;
    for (a = 0; a < n; a++) {
      cin >> b >> c >> d;
      num[b] += c, tan[b] += d;
    }
    for (a = 1; a <= 4000; a++) {
      if (num[a] * tan[a] >= 1000000) printf("%d\n", a), flag = true;
    }
    if (flag == false) printf("NA\n");
  }
  return 0;
}
