object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ")map(_.toInt))
    for (Array(n) <- in if n != 0) {
        val map = scala.collection.mutable.Map[Int, Long]().withDefaultValue(0)
        in.take(n.toInt).foreach{ case Array(e, p, q) => map(e) += p.toLong * q }
        val x = map.filter(_._2 >= 1000000).map(_._1)
        println(if (x.size == 0) "NA" else x.mkString("\n"))
    }
}