#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    queue<int> q;
    int d[4010] = {};
    int n;
    cin >> n;
    if (n == 0) break;
    int a, b, c;
    for (long long i = 0; i < n; i++) {
      cin >> a >> b >> c;
      if (d[a] == 0) {
        q.push(a);
      }
      d[a] += b * c;
    }
    int ct = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      if (d[x] >= 1000000) {
        cout << x << endl;
        ct++;
      }
    }
    if (ct == 0) {
      cout << "NA" << endl;
    }
  }
}
