#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int num, x, y;
    int mon = 0, cnt = 0;
    int p[4000];
    int j = 0;
    for (int i = 0; i < n; i++) p[i] = 0;
    for (int i = 0; i < n; i++) {
      cin >> num >> x >> y;
      mon = x * y;
      if (mon >= 1000000) {
        p[j] = num;
        cnt++;
        j++;
      }
    }
    if (cnt > 0) {
      for (int i = 0; i < cnt; i++) cout << p[i] << endl;
    }
    if (cnt == 0) cout << "NA" << endl;
  }
  return 0;
}
