#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n, f = 0, id;
    long long price, num, p[4000];
    for (int i = 0; i < 4001; i++) p[i] = 0;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> id >> price >> num;
      p[id] += price * num;
    }
    for (int i = 0; i < 4001; i++) {
      if (p[i] >= 1000000) {
        f = 1;
        cout << i << endl;
      }
    }
    if (f == 0) cout << "NA" << endl;
  }
  return 0;
}
