#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long sn, x, y;
  while (1) {
    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]) {
        swap(maxn, p[i]);
        maxc = i;
      }
    }
    if (maxn >= 1000000) {
      cout << maxc << endl;
    } else
      cout << "NA" << endl;
  }
}
