#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long sn, x, y;
  while (1) {
    vector<int> nm;
    long p[4001] = {0};
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> sn >> x >> y;
      p[sn] += x * y;
    }
    long maxn = 0;
    long maxc = 0;
    for (int i = 1; i <= 4000; i++) {
      if (maxn < p[i]) {
        nm.clear();
        swap(maxn, p[i]);
        nm.push_back(i);
      } else if (maxn == p[i]) {
        nm.push_back(i);
      }
    }
    if (maxn >= 1000000) {
      for (int i = 0; i < nm.size(); i++) {
        cout << nm[i] << endl;
      }
    } else
      cout << "NA" << endl;
  }
}
