object Main{

        def judeg(n:Array[Array[Int]]):Unit={
                var flag:Boolean = false
                def j(n:Array[Array[Int]],i:Int):Boolean= if( n(i)(1) * n(i)(2) >1000000) true else false

                for(i<- 0 until n.length){
                flag= j(n,i)
                if( flag == true) println(n(i)(0) )
                }
                if(flag == false) println("NA")

        }



        def main(args:Array[String]):Unit={
                val in = new java.util.Scanner(System.in)
                var v = 0
                try{
                        while({ v = in.nextInt;v != 0 }){
                                val a = Array.ofDim[Int](v,3)
                                        for(i <- 0 until v;j <- 0 to 2) a(i)(j)= in.nextInt
                                                judeg(a)
                        }

                }catch{
                case e: java.util.InputMismatchException =>                                      }
        }
}