#include <bits/stdc++.h>
using namespace std;
int main() {
  long long value[4001];
  int n, num, k, m;
  while (cin >> n && n) {
    memset(value, 0, sizeof(value));
    for (int i = 0; i < n; i++) {
      cin >> num >> k >> m;
      value[num] += k * m;
    }
    bool flag = true;
    for (int i = 0; i < 4001; i++) {
      if (value[i] >= 1000000) {
        flag = false;
        cout << i << endl;
      }
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
