import scala.collection.mutable import scala.io.StdIn.* import scala.math.* import scala.util.chaining.* @main def main = inline val p = 90007 val Array(_, q, x, y) = readLine().split(' ').map(_.toLong) val remQ = (0 to Int.MaxValue).collectFirst{case m if (y + m * q) % 10 != 0 && (y + m * q).toString.reverse.toLong % p != 0 => y + m * q}.get var rest = remQ.toString.reverse.toLong % p val result = mutable.StringBuilder(remQ.toString.reverse) while rest != x do rest = rest * 10 % p result.addOne('0') println(result.toString())