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