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