#include <bits/stdc++.h>
int main(void) {
  while (1) {
    int i, n;
    int emp[4001][2];
    int a, b, c;
    int flag = 1;
    scanf("%d", &n);
    if (!n) break;
    for (i = 1; i < 4001; i++) {
      emp[i][0] = 0;
      emp[i][1] = 0;
    }
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &a, &b, &c);
      if (!c || !b) continue;
      if (b > 1000000 / c) {
        emp[a][1] = 1;
        continue;
      }
      if (emp[a][0] > 1000000 - b * c) {
        emp[a][1] = 1;
        continue;
      }
      emp[a][0] += b * c;
    }
    for (i = 1; i < 4001; i++)
      if (emp[i][0] >= 1000000 || emp[i][1]) {
        printf("%d\n", i);
        flag = 0;
      }
    if (flag) printf("NA\n");
  }
  return (0);
}
