#include <bits/stdc++.h>
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    map<int, long long int> m;
    vector<int> num;
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      if (m.find(a) == m.end()) {
        num.push_back(a);
        m[a] = b * c;
      } else {
        m[a] += b * c;
      }
    }
    bool h = false;
    for (int i = 0; i < num.size(); i++) {
      if (m[num[i]] >= 1000000) {
        cout << num[i] << endl;
        h = true;
      }
    }
    if (!h) cout << "NA" << endl;
  }
}
