#include <bits/stdc++.h>
using namespace std;
int a[4000];
bool check[4000];
int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < 4000; i++) {
      a[i] = 0;
      check[i] = true;
    }
    bool na = true;
    long long b, c, d;
    for (int i = 0; i < n; i++) {
      cin >> b >> c >> d;
      a[b - 1] += c * d;
      if (a[b - 1] >= 1000000 && check[b - 1] == true) {
        check[b - 1] = false;
        na = false;
        cout << b << endl;
      }
    }
    if (na == true) cout << "NA" << endl;
  }
  return 0;
}
