import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(length, initial, diff, mod) = readLine.trim.split(' ').map(_.toLong)
  println((1 to 18).map{s ⇒ sumValueOfSameDigit(s)}.foldLeft(0L){(acc, i) ⇒ (acc + i) % mod})
  def power(base: Long, exp: Long): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base % mod
      case _ ⇒ power(base * base % mod, exp >> 1) * power(base, exp & 1) % mod
    }
  }
  def term(rank: Long): Long = {
    (initial % mod + diff % mod * (rank % mod)) % mod
  }
  def firstRankOver(digit: Int): Long = {
    if (digit > 18) length
    else {
      val min = (1 until digit).foldLeft(1L) { (acc, _) ⇒ acc * 10 }
      math.max(0, math.min(length, (min - initial + diff - 1) / diff))
    }
  }

  def sumValue(size: Int): Long = {
    val from = firstRankOver(size)
    val until = firstRankOver(size + 1)
    val len = until - from
    val first = term(from)
    val mul = power(10, size)
    val den = power(mul - 1, mod - 2)
    val muln = power(mul, len)
    val x = ((muln + mod - 1) % mod * den % mod - len) % mod
    val sumDiff= x * diff % mod * den % mod
    val sumFirst = (muln % mod + mod - 1) * den % mod * first % mod
    val upper = (size + 1 to 18).map{d ⇒ d * (firstRankOver(d + 1) - firstRankOver(d))}.sum
    (sumDiff + sumFirst) % mod * power(10, upper) % mod
  }
  def sumValueOfSameDigit(size: Int): Long = {
    val m = power(10, size)
    val from = firstRankOver(size)
    val until = firstRankOver(size + 1)
    val len = until - from
    val init = term(from)
    def multiplier(n: Long): Long = {
      n match {
        case 0L ⇒ 0
        case 1L ⇒ 1
        case _ if (n & 1) == 1 ⇒  (multiplier(n - 1) * m + 1) % mod
        case _ ⇒ multiplier(n >> 1).let{v ⇒ v * power(m, n >> 1) + v} % mod
      }
    }
    def multiplierN(n: Long): Long = {
      n match {
        case 0L ⇒ 0
        case 1L ⇒ 0
        case _ if (n & 1) == 1 ⇒ (multiplierN(n - 1) * m % mod + n - 1) % mod
        case _ ⇒ multiplierN(n >> 1).let{v ⇒ v * power(m, n >> 1) % mod + v + (n >> 1) % mod * multiplier(n >> 1) % mod} % mod
      }
    }
    val x = multiplier(len)
    val y = multiplierN(len)
    val upper = (size + 1 to 18).map(d ⇒ power(power(10, (firstRankOver(d + 1) - firstRankOver(d))), d)).foldLeft(1L){(acc, p) ⇒ acc * p % mod}
    //println(s"$init, $x, ${diff % mod}, $y")
    ((x * init % mod + diff % mod * y % mod) % mod * upper % mod)//.tap(println)
  }
  implicit class Scope[T](val receiver: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(receiver)
    def tap(@inline func: T ⇒ Unit): T = {
      func(receiver)
      receiver
    }
  }
}
