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