#include <bits/stdc++.h>
using namespace std;
int num[4001][2];
int main() {
  int n, i, j, id, l, m;
  while (cin >> n) {
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      cin >> id;
      if (num[id][0] == 0) {
        num[id][0] = id;
        cin >> num[id][0] >> num[id][1];
      } else {
        cin >> l >> m;
        num[id][0] += l;
        num[id][1] += m;
      }
    }
    int c = 0;
    for (i = 1; i <= 4000; i++) {
      if (num[i][0] == 0 && num[i][1] == 0) continue;
      if (num[i][0] * num[i][1] >= 1000000) {
        cout << i << endl;
        c++;
      }
      num[i][0] = 0;
      num[i][1] = 0;
    }
    if (c == 0) cout << "NA" << endl;
  }
  return 0;
}
