#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  while (cin >> N, N != 0) {
    vector<pair<int, int>> data;
    for (int i = 0; i < N; ++i) {
      int number, price, sales;
      cin >> number >> price >> sales;
      auto it = find_if(data.begin(), data.end(), [number](pair<int, int> x) {
        return x.first == number;
      });
      if (it != data.end()) {
        it->second += price * sales;
      } else {
        data.emplace_back(pair<int, int>{number, price * sales});
      }
    }
    int cnt = 0;
    for (const auto a : data) {
      if (a.second >= 1000000) {
        ++cnt;
        cout << a.first << endl;
      }
    }
    if (0 == cnt) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
