import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.LinkedHashMap

object Main extends App {
  Iterator.continually(readInt).takeWhile(_!=0).foreach { n =>
    val map = new LinkedHashMap[Long, Long]

    for(i<-1 to n) {
      val e = readLine.split(" ").map(_.toLong)
      if(!map.contains(e(0))) map += e(0) -> e(1)*e(2)
      else map(e(0)) += e(1)*e(2)
    }

    val filtered = map.filter( _._2 >= 1000000 )
    if(filtered.isEmpty) println("NA") else filtered.foreach( e => println(e._1))
  }
}