#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ID, price, quantity, sales[4001] = {0}, check;
  while (cin >> n) {
    int sales[4001] = {0};
    if (n == 0) break;
    check = 0;
    for (int i = 0; i < n; i++) {
      cin >> ID >> price >> quantity;
      sales[ID] += price * quantity;
      if (sales[ID] >= 1000000) {
        cout << ID << endl;
        check = 1;
        sales[ID] = -100000000;
      }
    }
    if (check == 0) cout << "NA" << endl;
  }
}
