#include <bits/stdc++.h>
using namespace std;
bool done[4096];
int main(void) {
  int n;
  while (1) {
    cin >> n;
    int flag = 0;
    if (n == 0) break;
    map<int, long long> m;
    m.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]) {
        m[bango] += tanka * num;
        if (m[bango] >= 1000000) {
          cout << bango << endl;
          done[bango] = true;
          flag = 1;
        }
      }
    }
    if (flag == 0) cout << "NA" << endl;
  }
  return 0;
}
