#include <bits/stdc++.h>
using namespace std;
int main() {
  int number, value, value_num;
  int num_data;
  int data[4000];
  while (true) {
    bool NA = false;
    cin >> num_data;
    if (num_data == 0) break;
    for (int ix = 0; ix != num_data; ++ix) {
      cin >> number;
      cin >> value >> value_num;
      data[number] += value * value_num;
    }
    for (int ix = 0; ix != 4000; ++ix) {
      if (data[ix] >= 1000000) {
        cout << ix << endl;
        NA = true;
      }
    }
    if (!NA) cout << "NA" << endl;
  }
  return 0;
}
