while 2 > 1:
    line_num = int(raw_input())
    if line_num < 1:
        break
    mydict = {}
    mydict_distinct = {}
    myIDlist = []
    for n in range(line_num):
        dat = map(int, raw_input().split(" "))
        if dat[0] in mydict_distinct:
            mydict[dat[0]] += dat[1] * dat[2]
        else:
            mydict[dat[0]] = dat[1] * dat[2]
            mydict_distinct[dat[0]] = 1
            myIDlist.append(dat[0])
    flg = 0
    for n in myIDlist:
        if mydict[n] > 999999:
            print n
            flg = 1
    if flg == 0:
        print 'NA'