#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
int main(void) {
  int n;
  while (cin >> n, n) {
    vector<ull> s(4010, 0);
    for (int i = 0; i < n; i++) {
      ll e, p, q;
      cin >> e >> p >> q;
      s[e - 1] += p * q;
    }
    bool flag = false;
    for (int i = 0; i < 4000; i++) {
      if (s[i] >= 1000000) {
        cout << i + 1 << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
