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