#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n) && n) {
    int a, b, c;
    map<int, long> list;
    vector<int> people;
    for (int i = 0; i < n; i++) {
      scanf("%d %d %d", &a, &b, &c);
      people.push_back(a);
      list[a] += b * c;
    }
    vector<int>::iterator it;
    bool flag = true;
    for (it = people.begin(); it != people.end(); it++) {
      if (list[*it] >= 1000000) {
        printf("%d\n", *it);
        flag = false;
      }
      list[*it] = 0;
    }
    if (flag) {
      printf("NA\n");
    }
  }
}
