#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool num[4000] = {false}, flag = false;
    int sum[4000] = {0}, m, ex, a;
    int c_num[4000] = {0};
    int c = 0;
    for (int i = 0; i < n; i++) {
      cin >> m >> ex >> a;
      sum[m] += ex * a;
      if (1000000 <= sum[m] && num[m] != true) {
        num[m] = true;
        c_num[c] = m;
        c++;
        flag = true;
      }
    }
    if (flag) {
      for (int i = 0; i < c; i++) {
        cout << c_num[i] << endl;
      }
    } else {
      cout << "NA" << endl;
    }
  }
  return (0);
}
