#include <bits/stdc++.h>
using namespace std;
long long t[4000], z, b, c;
int n, a, s[4000], u[4000], cnt;
void change(int x, int y) {
  int tmp;
  long long TMP;
  TMP = t[x];
  t[x] = t[y];
  t[y] = TMP;
  tmp = s[x];
  s[x] = s[y];
  s[y] = tmp;
  tmp = u[x];
  u[x] = u[y];
  u[y] = tmp;
}
void init() {
  for (int i = 0; i < 4000; i++) {
    t[i] = 0;
    s[i] = u[i] = 4001;
  }
  cnt = 0;
}
int main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    init();
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      a--;
      u[a] = a;
      z = b * c;
      t[a] = t[a] + z;
      if (s[a] == 4001) s[a] = i;
    }
    for (int i = 3999; i > 0; i--) {
      for (int j = 0; j < i; j++) {
        if (s[j] > s[j + 1]) {
          change(j, j + 1);
        }
      }
    }
    for (int i = 3999; i > 0; i--) {
      for (int j = 0; j < i; j++) {
        if (t[j] < t[j + 1]) {
          change(j, j + 1);
        }
      }
    }
    cnt = 0;
    for (int i = 0; i < 4000; i++) {
      if (t[i] >= 1000000) {
        cout << u[i] + 1 << endl;
        cnt = 1;
      } else {
        break;
      }
    }
    if (cnt == 0) cout << "NA" << endl;
  }
}
