#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  bool flag = true;
  int id_temp, price_temp, amount_temp;
  vector<int> id;
  vector<int> price;
  vector<int> amount;
  vector<int> result;
  while (true) {
    cin >> n;
    if (n < 0) {
      cout << "Error; n must be larger than 0";
      return -1;
    } else if (n == 0)
      break;
    else {
      result.clear();
      id.clear();
      price.clear();
      amount.clear();
      for (int i = 0; i < n; i++) {
        cin >> id_temp >> price_temp >> amount_temp;
        flag = true;
        for (int j = 0; j < id.size(); j++)
          if (id_temp == id[j]) {
            price[j] += price_temp;
            amount[j] += amount_temp;
            flag = false;
            break;
          }
        if (flag) {
          id.push_back(id_temp);
          price.push_back(price_temp);
          amount.push_back(amount_temp);
        }
      }
      for (int i = 0; i < n; i++)
        if (price[i] * amount[i] >= 1000000) result.push_back(id[i]);
      if (result.size() == 0)
        cout << "NA" << endl;
      else
        for (int i = 0; i < result.size(); i++) cout << result[i] << '\n';
    }
  }
  return 0;
}
