#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt, b, t, c, s, f;
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    cnt = 0;
    vector<pair<int, long long> > v;
    for (int i = 0; i < (n); i++) {
      scanf("%d%d%d", &b, &t, &c);
      s = v.size();
      f = 1;
      for (int i = 0; i < (s); i++)
        if (v[i].first == b) {
          v[i].second += t * c;
          f = 0;
        }
      if (f) v.push_back(pair<int, long long>(b, t * c));
    }
    s = v.size();
    for (int i = 0; i < (s); i++)
      if (v[i].second >= 1000000) {
        printf("%d\n", v[i].first);
        cnt++;
      }
    if (cnt == 0) puts("NA");
  }
  return 0;
}
