#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d = 0, com[4001] = {};
  cin >> n;
  if (n == 0) goto perm;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    com[a] += b * c;
  }
  for (int j = 1; j < 4001; j++) {
    if (com[j] >= 1000000) {
      cout << com[j] << endl;
      d++;
    }
  }
  if (d == 0) cout << "NA" << endl;
perm:
  return 0;
}
