#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  while (cin >> N, N) {
    pair<int, int> d[4001] = {};
    bool f = false;
    int a, b, c;
    for (int i = 0; i < N; i++) {
      cin >> a >> b >> c;
      int j;
      for (j = 0; d[j].first != 0; j++) {
        if (d[j].first == a) {
          d[j].second += b * c;
          if (d[j].second >= 1000000) f = true;
        }
      }
      if (d[j].first == 0) {
        d[j].first = a;
        d[j].second += b * c;
      }
    }
    if (!f)
      printf("NA\n");
    else
      for (int i = 0; d[i].first != 0; i++)
        if (d[i].second >= 1000000) printf("%d\n", d[i].first);
  }
  return 0;
}
