#include <bits/stdc++.h>
using namespace std;
ifstream fin("D:\\txt.txt");
map<int, int> data;
int main() {
  int n, a, b, c, i, j;
  while (cin >> n) {
    data.clear();
    if (!n) break;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      c *= b;
      if (data.find(a) == data.end()) {
        data.insert(map<int, int>::value_type(a, c));
      } else {
        data[a] += c;
      }
    }
    map<int, int>::iterator it = data.begin();
    bool bo = true;
    while (it != data.end()) {
      if (1000000 <= it->second) {
        cout << it->first << endl;
        bo = false;
      }
      it++;
    }
    if (bo) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
