object Main extends App {
  def m(s: String): Int = {
    val input = s.split(" ").map(_.toInt).toList
    val a = for {
      n <- 1 until input(2)
      x = input.head
      d = input(1)
    } yield x + (d * n) % 1000003
    (input.head :: a.toList).reduce(_ * _ % 1000003)
  }

  val q = readInt()

  for {
    q <- 1 to q
  } println(m(readLine()))
}