l, a, b, md = gets.split.map(&:to_i)

def getlen(a)
  res = 0
  while a > 0
    res += 1
    a /= 10
  end
  res
end

def modpow(a, b, md)
  res = 1
  while b > 0 
    if b.odd? 
      res = res * a % md
    end
    a = a * a % md
    b /= 2
  end
  res
end

def length(a, b, n)
  return getlen(a) if n == 1
  k = n / 2
  length(a, b, k) + length(a + b * k, b, n - k)
end

def f(a, b, n, md)
  return a if n == 1
  k = n / 2
  l = modpow(10, length(a + b * k, b, n - k), md)
  (f(a, b, k, md) * l + f(a + b * k, b, n - k, md)) % md
end

puts f(a, b, l, md)
