local n, a, b, mod = io.read("*n", "*n", "*n", "*n")

local function badd(x, y) return (x + y) % mod end
local function bsub(x, y) return (mod + x - y) % mod end
local function bmul(x, y) return (x * y) % mod end
local function bmul_m(x, y) return (x * y) % (mod - 1) end
local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res, pow = bmul(res, src), pow - 1
    end
    src, pow = bmul(src, src), pow // 2
  end
  return res
end

local function func(i)
  local c, z = 0, a + b * (i - 1)
  while 0 < z do
    c, z = c + 1, z // 10
  end
  return c
end

local function getright(d, left)
  local min = left
  local max = n
  if d < func(min) then return left - 1 end
  if func(max) == d then return max end
  while 1 < max - min do
    local mid = (min + max) // 2
    if d < func(mid) then max = mid
    else min = mid
    end
  end
  return min
end

local function solve1(d, n)
  if n == 1 then return 1 end
  local add = 0
  local tend = modpow(10, d)
  if n % 2 == 1 then
    add = add + modpow(tend, n - 1)
    n = n - 1
  end
  n = n // 2
  local v = solve1(d, n)
  v = bmul(v, badd(1, modpow(tend, n)))
  return badd(add, v)
end

local function solve2(d, n)
  if n == 1 then return 0 end
  local add = 0
  local tend = modpow(10, d)
  if n % 2 == 1 then
    add = add + bmul(n - 1, modpow(tend, n - 1))
    n = n - 1
  end
  n = n // 2
  local v1 = solve2(d, n)
  v1 = bmul(v1, badd(1, modpow(tend, n)))
  local v2 = solve1(d, n)
  v2 = bmul(v2, bmul(n % mod, modpow(tend, n)))
  return badd(add, badd(v1, v2))
end

local cur_digsum = 0
local left = 1
local ret = 0
for d = 1, 18 do
  local right = getright(d, left)
  if left <= right then
    local s1 = solve1(d, right - left + 1)
    local v1 = bmul(a % mod, s1)
    local v2 = bmul(b % mod, (right - 1) % mod)
    v2 = bmul(v2, s1)
    local v3 = bmul(b % mod, solve2(d, right - left + 1))
    ret = bmul(ret, modpow(10, bmul_m((right - left + 1), d)))
    ret = badd(ret, badd(v1, bsub(v2, v3)))
    cur_digsum = cur_digsum + (right - left + 1) * d
    left = right + 1
  end
  if n < left then break end
end
print(ret)
