#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    vector<int> a;
    vector<long long> b;
    vector<long long> c;
    int x, y, z;
    map<int, long long> sum;
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> z;
      a.push_back(x);
      b.push_back(y);
      c.push_back(z);
      sum[x] += y * z;
    }
    int cnt = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) {
      cout << a[i] << endl;
    }
    for (int i = 0; i < n; i++) {
      if (sum[a[i]] >= 1000000 && a[i] != a[i + 1]) {
        cout << a[i] << endl;
        cnt++;
      }
    }
    if (cnt == 0) cout << "NA" << endl;
  }
  return 0;
}
