#include <bits/stdc++.h>
using namespace std;
const long long N = 4005, M = 1000000;
map<long long, long long> m;
signed main(void) {
  long long n, flag;
  ios::sync_with_stdio(false);
  while (cin >> n && n) {
    m.clear();
    flag = 1;
    for (long long i = 1, x, y, z; i <= n; i++) {
      cin >> x >> y >> z;
      m[x] += y * z;
    }
    for (map<long long, long long>::iterator it = m.begin(); it != m.end();
         ++it)
      if (it->second >= M) cout << it->first << endl, flag = 0;
    if (flag) cout << "NA" << endl;
  }
}
