#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
    int box[4000];
    for (int i = 0; i < 4000; i++) {
      box[i] = 0;
    }
    cin >> a;
    if (a == 0) {
      break;
    }
    for (int i = 0; i < a; i++) {
      cin >> b;
      cin >> c;
      cin >> d;
      box[b - 1] += c * d;
    }
    for (int i = 0; i < 4000; i++) {
      if (box[i] >= e) {
        e = box[i];
        f = b + 1;
      }
    }
    if (e <= 1000000) {
      cout << "NA" << endl;
    } else {
      cout << b << endl;
    }
  }
  return 0;
}
