import java.util.*

fun main(args: Array<String>){
    var scn = Scanner(System.`in`)
    var n:Int = scn.nextInt()
    var emp = LongArray(4001)
    var num:Int
    var p:Long
    var q:Long
    var exist = false
    while(n != 0){
        exist = false
        for(i in 1..n) {
            num = scn.nextInt()
            p = scn.nextLong()
            q = scn.nextLong()
            emp[num] += p * q
        }
        for(i in 1..4000){
            if(emp[i] >= 1_000_000){
                exist = true
                println(i)
            }
        }
        if(!exist)println("NA")
        n = scn.nextInt()
        emp = LongArray(4001)
    }
}


