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