#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int main() {
  int n;
  while (cin >> n, n) {
    int a, b, c;
    map<int, int> m;
    bool flag = false;
    for (int i = 0; i < (n); i++) {
      cin >> a >> b >> c;
      m[a] += b * c;
    }
    for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
      if (it->second >= 1000000) {
        cout << it->first << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
}
