While True:
    no = []
    n = int(input())
    if (n = 0):
        return
    
    for i in range(n):
        datas = map(int, input().split())
        li = list(datas) 
        e = li[0]
        p = li[1]
        q = li[2]

        s = p * q
        if (1000000 < s and (e in no) = False):
            print(e)
            no.append(e)
    
    if (len(no) = 0):
        print("NA")


