#include <bits/stdc++.h>
using namespace std;
long long int p[114514], x, y, z;
int main(void) {
  int i, j, k, f, n, cnt;
  while (1) {
    cin >> n;
    f = 0, cnt = 0;
    if (!n) break;
    for (i = 0; i < 4001; i++) p[i] = 0;
    for (i = 0; i < n; i++) {
      cin >> x >> y >> z;
      p[x] += (y * z);
    }
    for (i = 0; i < 4001; i++) {
      if (p[i] >= 1000000) {
        cout << i << endl;
        f = 1;
      }
    }
    if (f == 0) cout << "NA" << endl;
  }
  return 0;
}
