L, A, B, M = gets.split.map(&:to_i)

require 'matrix'

def mpow(x, n)
  ret = Matrix.I(3)
  while n > 0
    if n.even?
      x = (x * x).map{|e| e % M}
      n >>= 1
    else
      ret = (ret * x).map{|e| e % M}
      n -= 1
    end
  end
  ret
end

s = ->(n){A + B*n}
u = ->(k){(0 ... L).bsearch{|i| s[i] >= 10**(k - 1)} || L}
x = ->(k, n){mpow(Matrix[[10**k, 1, 0], [0, 1, B], [0, 0, 1]], n)}
m = 19.downto(1).each_cons(2).map{|a, b| x[b, u[a] - u[b]]}.inject(:*) * Matrix.column_vector([0, A, 1])
puts m.first % M