#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int aa[10000] = {0}, x = 0, y = 0, z = 0, flg = 0, a;
  while (cin >> a) {
    if (a == 0) break;
    for (int i = 0; i < a; i++) {
      cin >> x >> y >> z;
      aa[x] += y * z;
    }
    for (int i = 0; i < 4010; i++) {
      if (aa[i] >= 1000000) {
        flg = 1;
        cout << i << endl;
      }
    }
    if (flg == 0) cout << "NA" << endl;
    for (int i = 0; i < 4010; i++) {
      aa[i] = 0;
      flg = 0;
    }
  }
  return 0;
}
