/* AOJ 0100
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100
 *
 */

#include <stdio.h>
#include <assert.h>

typedef struct TEntry Entry;
struct TEntry {
    int fID;
    int fSales;
};

int cmp(const void*a, const void*b){
    return ((Entry*)b)->fSales - ((Entry*)a)->fSales;
}

int main(){
    int n, i;
    char buf[80];
    int id, at, count;
    Entry sales[4000];

    Entry *p;

    while(scanf("%d", &n)==1 && n){
        for(i=0;i<4000;i++){
            sales[i].fID = i+1;
            sales[i].fSales = 0;
        }

        for(i=0;i<n;i++){
            scanf("%d %d %d", &id, &at, &count);
            sales[id-1].fSales += at*count;
            assert(id == sales[id-1].fID);
        }
        qsort(sales, 4000, sizeof(Entry), cmp);

        p = sales;
        if (p->fSales >= 1000000){
            while(p->fSales >= 1000000){
                printf("%d\n", p->fID);
                p++;
            }
        }else{
            printf("NA\n");
        }
    }

    return 0;
}