while True:
    flg = True
    inf = []
    dic = {}
    n = int(input())
    if n==0:
        break
    for i in range(n):
        inf.append(list(map(int,input().split())))
        if inf[i][0] in dic:
            tmp = dic[inf[i][0]] + inf[i][1]*inf[i][2]
            dic[inf[i][0]] = tmp
        else:
            dic[inf[i][0]] = inf[i][1]*inf[i][2]

    for shain_id,sale in dic.items():
        if sale >= 1000000:
            print(shain_id)
            flg = False
    if flg:
        print("NA")
        

    # for i in inf:

