#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int ID, price, sale;
    int table[4096];
    bool flag = false;
    memset(table, 0, sizeof(table));
    for (int i = 0; i < n; i++) {
      cin >> ID >> price >> sale;
      table[ID] += price * sale;
    }
    for (int i = 0; i < 4096; i++) {
      if (table[i] >= 1000000) {
        cout << i << endl;
        flag = true;
      }
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
