#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
int main() {
  int n, m;
  while (cin >> n, n) {
    long long v[4010];
    for (int j = (0); j < unsigned long long(4010); ++j) v[j] = 0;
    for (int p = (0); p < unsigned long long(n); ++p) {
      int a, b, c;
      cin >> a >> b >> c;
      v[a] += b * c;
    }
    bool isP = false;
    for (int i = (0); i < unsigned long long(4010); ++i)
      if (1000000 <= v[i]) {
        isP = true;
        cout << i << endl;
      }
    if (!isP) cout << "NA" << endl;
  }
}
