#include <bits/stdc++.h>
using namespace std;
int main() {
  long long u[4010];
  vector<int> v;
  bool k;
  while (1) {
    for (int i = 0; i < 4010; i++) {
      u[i] = 0;
    }
    k = true;
    int n;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      int x, y, z;
      cin >> x >> y >> z;
      u[x] += (long long)y * (long long)z;
    }
    for (int i = 0; i < 4010; i++) {
      if (u[i] >= 1000000) {
        k = false;
        cout << i << endl;
      }
    }
    if (k) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
