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