#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int a, b, c;
    map<int, int> m;
    vector<int> v;
    bool flag = false;
    for (int i = 0; i < (n); i++) {
      cin >> a >> b >> c;
      if (m[a] == 0) {
        v.push_back(a);
      }
      m[a] += b * c;
    }
    for (int i = 0; i < (v.size()); i++) {
      if (m[v[i]] >= 1000000) {
        cout << v[i] << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
}
