#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    long long arr[4001];
    long long selling;
    long long sales;
    long long num;
    int check = 0;
    memset(arr, 0, sizeof(arr));
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> num >> selling >> sales;
      arr[num] += selling * sales;
    }
    for (int i = 0; i <= 4000; i++) {
      if (arr[i] >= 1000000) {
        cout << i << endl;
        check++;
      }
    }
    if (check == 0) cout << "NA" << endl;
    check = 0;
  }
}
