#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c, a, b;
  while (1) {
    int cc = 0, t[4010] = {}, f[4010] = {};
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> c >> a >> b;
      t[c] += a * b;
      if (t[c] >= 1000000 && f[c] == 0) {
        cout << c << endl;
        cc++;
        f[c] = 1;
      }
    }
    if (cc == 0) cout << "NA" << endl;
  }
}
