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