#include <bits/stdc++.h>
using namespace std;
long long employees[4001];
bool checked[4001];
int main() {
  int n;
  while (cin >> n, n) {
    for (int i = 1; i <= 4000; ++i) employees[i] = checked[i] = false;
    vector<int> ans;
    for (int i = 0; i < n; ++i) {
      int num, a, b;
      cin >> num >> a >> b;
      if (checked[num]) continue;
      employees[num] += a * b;
      if (employees[num] >= 1000000) {
        ans.push_back(num);
        checked[num] = true;
      }
    }
    if (ans.empty()) cout << "NA" << endl;
    for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
  }
}
