#include <bits/stdc++.h>
int main() {
  int i, j, n, x, y, k, s = 1, p, q = 0;
  static int a[4000][3];
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (i = 0; i < n; i++) {
      scanf("%d", &k);
      scanf("%d %d", &x, &y);
      if (a[k][0] == 0) {
        a[k][0] = k;
        a[k][1] = x * y;
        a[k][2] = s;
        s++;
      } else {
        a[k][1] = a[k][1] + x * y;
      }
    }
    for (i = 1; i < 4000; i++) {
      for (j = i + 1; j <= 4000; j++) {
        if (a[i][2] < a[j][2]) {
          p = a[i][0];
          a[i][0] = a[j][0];
          a[j][0] = p;
          p = a[i][1];
          a[i][1] = a[j][1];
          a[j][1] = p;
          p = a[i][2];
          a[i][2] = a[j][2];
          a[j][2] = p;
          if (p != 0) {
            q++;
          }
        }
      }
    }
    j = 0;
    for (i = q; i >= 0; i--) {
      if (a[i][0] != 0 && a[i][1] >= 1000000) {
        printf("%d\n", a[i][0]);
        j++;
        a[i][0] = 0;
        a[i][1] = 0;
        a[i][2] = 0;
      } else if (a[i][0] != 0 || a[i][1] != 0 || a[i][3] != 0) {
        a[i][0] = 0;
        a[i][1] = 0;
        a[i][2] = 0;
      }
    }
    if (j == 0) {
      printf("NA\n");
    }
    q = 0;
    s = 1;
  }
  return 0;
}
