while True:
    input_n = int(input())
    key = 0
    if input_n == 0:
        break
    id_list = [[0 for i in range(2)]for i in range(input_n)]
    for i in range(input_n):
        id_line = input().split()
        for j in id_list:
            if j[0] == int(id_line[0]):
                j[1] += int(id_line[1]) * int(id_line[2])
                uriage = j[1]
                break
        else:
            id_list[i][0] = int(id_line[0])
            id_list[i][1] = int(id_line[1]) * int(id_line[2])
            uriage = id_list[i][1]
        if uriage >= 1000000:
            key = 1
    
    for i in id_list:
        if key == 0:
            print("NA")
            break
        if i[1] >= 1000000:
            print(i[0])
