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

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

typedef long long int bigint;

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

int cmp(const void*p, const void*q){
    bigint a, b;
    a = ((Entry*)p)->fSales;
    b = ((Entry*)q)->fSales;
    if(a>b)
        return -1;
    else if (a < b)
        return 1;
    else
        return 0;
}
/*
 * needed
 * 100,000,000,000
 * int 
 * 2,147,483,647
 * uint 
 * 4,294,967,295
 *
 *
 */

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

    Entry *p;

    assert(sizeof(bigint) > 4);

    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;
}