#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, k, l;
  int n;
  long long id, cost, qty;
  long long data_list[10000];
  int id_list[10000];
  bool id_flag;
  bool na_flag;
  while (cin >> n, n != 0) {
    fill(data_list, data_list + 4000, 0);
    k = 0;
    for (l = 0; l < n; l++) {
      data_list[id] += (cost * qty);
      cin >> id >> cost >> qty;
      id_flag = true;
      for (i = 0; i <= k + 1; i++) {
        if (id_list[i] == id) {
          id_flag = false;
        }
      }
      if (id_flag) {
        id_list[k] = id;
        k++;
      }
    }
    na_flag = true;
    for (l = 0; l < k; l++) {
      if (data_list[id_list[l]] >= 1000000) {
        cout << id_list[l] << endl;
        na_flag = false;
      }
    }
    if (na_flag) {
      cout << "NA" << endl;
    }
  }
  return (0);
}
