#include <bits/stdc++.h>
using namespace std;
vector<int> hoge;
map<int, int> sums;
bool input() {
  hoge.clear();
  sums.clear();
  int n;
  cin >> n;
  if (n == 0) return false;
  for (int i = 0; i < int(n); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    sums[a] += b * c;
  }
  for (auto i : sums) {
    if (i.second >= 1000000) hoge.push_back(i.first);
  }
  return true;
}
void solve() {
  if (hoge.size() == 0)
    puts("NA");
  else {
    for (int i = 0; i < int(hoge.size()); i++) {
      printf("%d\n", hoge[i]);
    }
  }
}
int main() {
  while (input()) {
    solve();
  }
}
