#include <bits/stdc++.h>
using namespace std;
bool done[4096];
vector<int> syain;
int main(void) {
  int n;
  while (1) {
    cin >> n;
    int flag = 0;
    if (n == 0) break;
    map<int, long long> m;
    m.clear();
    syain.clear();
    for (int i = 0; i < 4096; i++) done[i] = false;
    for (int i = 0; i < n; i++) {
      int bango, tanka, num;
      cin >> bango >> tanka >> num;
      if (!done[bango]) {
        done[bango] = true;
        syain.push_back(bango);
      }
      m[bango] += (m[bango] >= 1000000) ? 0 : tanka * num;
    }
    for (int i = 0; i < syain.size(); i++) {
      if (m[syain[i]] >= 1000000) {
        cout << syain[i] << endl;
        flag = 1;
      }
    }
    if (flag == 0) cout << "NA" << endl;
  }
  return 0;
}
