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