object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        for (Array(n) <- in if n != 0) {
            val map = in.take(n.toInt).foldLeft(Map[Int, BigInt]())((acc, x) => x match {
                case Array(e, p, q) =>
                    if (acc contains e) acc.updated(e, acc(e) + BigInt(p) * q)
                    else acc + (e -> BigInt(p) * q)
            })
            val x = map.filter(_._2 >= 1000000).map(_._1)
            println(if (x.size == 0) "NA" else x.mkString("\n"))
        }
    }
}