#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    queue<int> output;
    long long man[5000] = {};
    for (int i = 0; i < (n); i++) {
      int a, b, c;
      cin >> a >> b >> c;
      if (man[a] == 0) {
        output.push(a);
      }
      man[a] += b * c;
    }
    bool flag = true;
    while (output.size()) {
      if (man[output.front()] >= 1000000) {
        cout << output.front() << endl;
        flag = false;
      }
      output.pop();
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
