#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (cin >> n, n) {
    int list[4001] = {0};
    int a, b, c;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      list[a] += b * c;
    }
    bool check = true;
    for (int i = 1; i <= 4000; i++)
      if (list[i] >= 1000000) cout << i << endl, check = false;
    if (check) cout << "NA" << endl;
  }
  return 0;
}
