#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n, no[4002], unit, qua;
    int emp[4002] = {0};
    int empflag[4002] = {0};
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      scanf("%d %d %d", &no[i], &unit, &qua);
      emp[no[i]] += unit * qua;
    }
    sort(no, no + n);
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (emp[no[i]] >= 1000000 && empflag[no[i]] == 0) {
        printf("%d\n", no[i]);
        flag = 1;
        empflag[no[i]] = 1;
      }
    }
    if (flag == 0) printf("NA\n");
  }
  return (0);
}
