#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    long long emp[4001];
    vector<int> nums;
    bool exist = false;
    memset(emp, 0, sizeof(emp));
    for (int i = 0; i < n; i++) {
      int num;
      long long val, am;
      cin >> num >> val >> am;
      emp[num] += val * am;
      if (find(nums.begin(), nums.end(), num) == nums.end()) {
        nums.push_back(num);
      }
    }
    for (int i = 0; i < nums.size(); i++) {
      if (emp[nums[i]] >= 1000000) {
        exist = true;
        cout << nums[i] << endl;
      }
    }
    if (!exist) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
