#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
map<int, long long> data;
int main() {
  int n;
  while (cin >> n, n) {
    data.clear();
    std::vector<int> a;
    a.clear();
    for (int i = 0; i < (n); i++) {
      int e, c, s;
      cin >> e >> c >> s;
      if (!data[e]) {
        a.push_back(e);
      }
      data[e] += (c * s);
    }
    bool flag = false;
    for (int i = 0; i < a.size(); i++) {
      if (data[a[i]] >= 1000000) {
        cout << a[i] << endl;
        flag = true;
      }
    }
    if (!flag) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
