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