#include <bits/stdc++.h>
using namespace std;
int n;
int s[4000];
int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 0; i < (n); ++i) {
      int a, x, y;
      scanf("%d%d%d", &a, &x, &y);
      s[--a] = (int)min(s[a] + long long(x) * y, long long(1e6));
    }
    bool none = true;
    for (int i = 0; i < (4000); ++i) {
      if (s[i] >= (int)1e6) {
        printf("%d\n", i + 1);
        none = false;
      }
      s[i] = 0;
    }
    if (none) {
      puts("NA");
    }
  }
  return 0;
}
