#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, a, b, c, n, emp[4001] = {};
  while (1) {
    t = 0;
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; ++i) {
      cin >> a >> b >> c;
      emp[a] += b * c;
    }
    for (int i = 1; i < 4001; ++i) {
      if (emp[a] >= 1000000) {
        cout << a << endl;
        t++;
      }
    }
    if (t == 0) cout << "NA" << endl;
  }
  return 0;
}
