#include <bits/stdc++.h>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    long long member[4001] = {0};
    int a, b, c;
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      member[a] += b * c;
    }
    int count = 0;
    for (int i = 0; i < 4001; i++) {
      if (member[i] >= 1000000) {
        count++;
        cout << i << endl;
      }
    }
    if (count == 0) cout << "NA" << endl;
  }
}
