#include <bits/stdc++.h>
using namespace std;
struct sale {
  int price;
  int num;
};
int main() {
  while (1) {
    int n, cost, piece, num, count = 0;
    cin >> n;
    if (n == 0) break;
    sale a[4000];
    for (int i = 0; i < 4000; i++) {
      a[i].price = 0;
      a[i].num = 0;
    }
    for (int i = 0; i < n; i++) {
      cin >> num >> cost >> piece;
      a[num - 1].price += cost;
      a[num - 1].num += piece;
    }
    for (int i = 0; i < 4000; i++) {
      if (a[i].price * a[i].num >= 1000000) {
        cout << i + 1 << endl;
        count++;
      }
    }
    if (count == 0) cout << "NA" << endl;
  }
  return 0;
}
