#include <bits/stdc++.h>
using namespace std;
int n, id, p, q;
long long amount;
const long long MAX = 1000000;
struct Mem {
  int index;
  int id;
  Mem(int _index, int _id) {
    index = _index;
    id = _id;
  }
  bool operator<(const Mem& m) const { return index < m.index; }
};
map<Mem, long long> m;
map<Mem, long long>::iterator it;
vector<int> ans;
int main(void) {
  freopen("i.in", "r", stdin);
  while (~scanf("%d", &n)) {
    if (n == 0) break;
    m.clear();
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", &id, &p, &q);
      amount = p * q;
      Mem tmp(i, id);
      m[tmp] += amount;
    }
    ans.clear();
    for (it = m.begin(); it != m.end(); it++) {
      if ((*it).second >= MAX) {
        ans.push_back((*it).first.id);
      }
    }
    if (ans.empty()) {
      printf("NA\n");
    } else {
      for (int i = 0; i < (int)ans.size(); i++) {
        printf("%d\n", ans[i]);
      }
    }
  }
  return 0;
}
