#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (!n) break;
    double salesOfEmployee[4000 + 1];
    for (int i = 0; i <= 4000; i++) salesOfEmployee[i] = 0;
    int id;
    double price, quantity;
    for (int i = 0; i < n; i++) {
      cin >> id >> price >> quantity;
      salesOfEmployee[id] += price * quantity;
    }
    int flag = 0;
    for (int i = 1; i <= 4000; i++) {
      if (salesOfEmployee[i] >= 1000000) {
        cout << i << endl;
        flag = 1;
      }
    }
    if (!flag) cout << "NA" << endl;
  }
  return 0;
}
