#include <bits/stdc++.h>
using namespace std;
int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<long long int> num(4001, 0), pre(n, 0), data(4001, 0);
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      if (data[a] < 1000000) data[a] += b * c;
      if (num[a] == 0) num[a] = i + 1;
    }
    for (int k = 0; k < 4001; k++) {
      if (num[k] != 0) pre[num[k]] = k;
    }
    long long int ch = 0;
    for (int j = 0; j < n; j++) {
      if (data[pre[j]] >= 1000000) {
        cout << pre[j] << endl;
        ch++;
      }
    }
    if (ch == 0) cout << "NA" << endl;
  }
}
