#include <bits/stdc++.h>
using namespace std;
struct data {
  int a, total;
};
int main() {
  int i, j, n, c, a, yen, ko, f, f2, con;
  data d[4000];
  while (1) {
    cin >> n;
    if (n == 0) break;
    c = 0;
    con = 0;
    for (i = 0; i < n; i++) {
      cin >> a;
      f = 1;
      for (j = 0; j < i; j++) {
        if (a == d[j].a) {
          cin >> yen >> ko;
          d[j].total += yen * ko;
          f = 0;
          con++;
          break;
        }
      }
      if (f) {
        cin >> yen >> ko;
        d[i - con].a = a;
        d[i - con].total = yen * ko;
        c++;
      }
    }
    f2 = 1;
    for (i = 0; i < c; i++) {
      if (d[i].total >= 1000000) {
        cout << d[i].a << endl;
        f2 = 0;
      }
    }
    if (f2) cout << "NA" << endl;
  }
  return 0;
}
