#include <bits/stdc++.h>
using namespace std;
int p[4001];
int result[1000000];
int main() {
  int i, j = 0, n, id, price, num, cnt;
  while (cin >> n) {
    cnt = 0;
    memset(p, 0, sizeof(p) / sizeof(p[0]));
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      cin >> id >> price >> num;
      p[id] += price * num;
    }
    for (i = 0; i < 4001; i++) {
      if (p[i] >= 1000000) {
        result[j++] = i;
        cnt++;
      }
    }
    if (cnt == 0) {
      result[j++] = 0;
    }
  }
  for (i = 0; i < j; i++) {
    if (result[i] == 0) {
      cout << "NA" << endl;
    } else {
      cout << result[i] << endl;
    }
  }
  return 0;
}
