#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int number[4000] = {0};
  int tanka;
  int ryou;
  long long goukei[4000] = {0};
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> number[i];
      cin >> tanka;
      cin >> ryou;
      goukei[i] = tanka * ryou;
    }
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (number[i] == number[j]) {
          goukei[i] += goukei[j];
          if (goukei[i] >= 1000000) goukei[i] = 1000000;
          goukei[j] = 0;
        }
      }
    }
    int flag = -1;
    for (int i = 0; i < n; i++) {
      if (goukei[i] >= 1000000) {
        flag = 0;
        cout << number[i] << endl;
      }
    }
    if (flag == -1) cout << "NA" << endl;
  }
  return 0;
}
