#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n;
    scanf(" %d", &n);
    if (n == 0) break;
    vector<int> bangoulist;
    map<int, long long int> alldata;
    alldata.clear();
    for (int i = 0; i < n; i++) {
      int bangou, tanka, num;
      scanf(" %d %d %d", &bangou, &tanka, &num);
      if (alldata[bangou] != 0) {
        alldata[bangou] += tanka * num;
      } else {
        bangoulist.push_back(bangou);
        alldata[bangou] = tanka * num;
      }
    }
    bool flag = true;
    for (int i = 0; i < (int)bangoulist.size(); i++) {
      if (alldata[bangoulist[i]] >= 1000000) {
        cout << bangoulist[i] << "\n";
        flag = false;
      }
    }
    if (flag) cout << "NA\n";
  }
  return 0;
}
