#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
int main() {
  while (1) {
    int N;
    cin >> N;
    if (!N) break;
    map<int, long long int> mp;
    for (int i = 0; i < N; ++i) {
      long long int a, b, c;
      cin >> a >> b >> c;
      mp[a] += b * c;
    }
    bool flag = false;
    for (auto m : mp) {
      if (m.second >= 1000000) {
        cout << m.first << endl;
        flag = true;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
