import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    while (true) {
      val n = readLine.toInt
      if (n == 0) return

      var map = scala.collection.mutable.Map[Int, Int]()

      for (i <- 0 until n) {
        val s = readLine.split(' ').map(x => x.toInt)
        val emp = s(0)
        val price = s(1)
        val num = s(2)
        map += emp -> (map.getOrElse(emp, 0) + price * num)
      }
      map.filter(t => t._2 >= 1000000).keys.foreach(println)
    }
  }
}