#include <bits/stdc++.h>
using namespace std;
int main() {
  long long number[4001] = {};
  long long e, p, q;
  int MAX = 0;
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> e >> p >> q;
      if (MAX <= e) {
        MAX = e;
      }
      number[e - 1] += p * q;
    }
  }
  int x = 0;
  for (int i = 0; i < e; i++) {
    if (number[i] >= 1000000) {
      cout << number[i];
      x++;
    }
  }
  if (x == 0) {
    cout << "NA" << endl;
  }
  return 0;
}
