#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int data[4001];
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (int i = 1; i <= 4000; i++) {
      data[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      data[a] += b * c;
    }
    bool f = false;
    for (int i = 1; i <= 4000; i++) {
      if (data[i] >= 1000000) {
        cout << i << endl;
        f = true;
      }
    }
    if (!f) cout << "NA" << endl;
  }
  return 0;
}
