#include <bits/stdc++.h>
using namespace std;
int s[4001], n, a, b, N;
string d;
int main() {
  while (cin >> N) {
    if (N == 0) return 0;
    fill(s, s + 4001, 0);
    for (int i = 0; i < N; i++) {
      cin >> n >> a >> b;
      s[n] += a * b;
    }
    int flag = 0;
    for (int i = 0; i < 4001; i++)
      if (s[i] > 999999) {
        cout << i << endl;
        flag = 1;
      }
    if (flag == 0) cout << "NA" << endl;
  }
}
