#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool hantei = true, kaburi[n];
    long long number[n], price[n], quantity[n], sale[n];
    for (int i = 0; i < n; i++) {
      cin >> number[i] >> price[i] >> quantity[i];
      if (price[i] < 0 && quantity[i] < 0) {
        sale[i] = 0;
      } else {
        sale[i] = price[i] * quantity[i];
      }
    }
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (number[i] == number[j]) {
          kaburi[j] = true;
          sale[i] += (price[j] * quantity[j]);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      if (kaburi[i]) {
        continue;
      }
      if (sale[i] >= 1000000) {
        cout << number[i] << endl;
        hantei = false;
      }
    }
    if (hantei) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
