import scala.collection.mutable.* import scala.io.StdIn.* import scala.util.chaining.* import scala.math.* import scala.reflect.ClassTag import scala.util.* import scala.annotation.tailrec import scala.collection.mutable extension (value: Int) def powMod(exp: Int, mod: Int): Long = var result = 1L var base = value.toLong % mod var e = exp while e > 0 do if (e & 1) == 1 then result = result * base % mod base = base * base % mod e >>= 1 result @main def main = val testCase = readLine.toInt for _ <- 0 until testCase do val Array(a, b, c) = readLine.split(' ').map(_.toInt) val r = a * 10.powMod(c - 1, b) % b println(r * 10 / b)