#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  int n, f, i;
  long long int ID, price, num;
  long long int sum[4001];
  int ln, list[4000];
  while (1) {
    scanf("%d ", &n);
    if (!n) break;
    f = 0;
    ln = 0;
    for (i = 1; i < 4001; i++) sum[i] = 0;
    while (n--) {
      scanf("%lld %lld %lld ", &ID, &price, &num);
      sum[ID] += price * num;
      list[ln++] = ID;
    }
    for (i = 0; i < ln; i++)
      if (1000000 <= sum[list[i]]) {
        printf("%dn", list[i]);
        f = 1;
        sum[list[i]] = 0;
      }
    if (!f) printf("NAn");
  }
  return 0;
}
