using CompLib.Util;
using System;
using System.Linq;

public class Program
{
    long L, A, B, M;
    public void Solve()
    {
        var sc = new Scanner();
        L = sc.NextLong();
        A = sc.NextLong();
        B = sc.NextLong();
        M = sc.NextLong();

        // 初項の桁数
        int lenA = A.ToString().Length;

        // 末項の桁数
        int lenLast = (A + B * (L - 1)).ToString().Length;


        // 桁数で分類
        long f = 0;

        // 10^d
        long p = 1;
        for (int i = 0; i < lenA; i++)
        {
            p *= 10;
            p %= M;
        }
        long ans = 0;
        for (int d = lenA; d <= lenLast; d++)
        {
            if ((A + (B * f)).ToString().Length > d)
            {
                p *= 10;
                p %= M;
                continue;
            }



            // 桁数がdになる最大
            long ok = f;
            long ng = L;



            while (ng - ok > 1)
            {
                long med = (ok + ng) / 2;
                int len = (A + B * (med)).ToString().Length;
                if (len <= d)
                {
                    ok = med;
                }
                else
                {
                    ng = med;
                }
            }

            // [f, ok]がd桁になる範囲

            long aa = (A + B * f) % M;

            long[][] a = new long[1][] { new long[3] { aa, B % M, 0 } };
            long[][] b = new long[3][] { new long[] { 1, 0, 1 }, new long[] { 1, 1, 0 }, new long[] { 0, 0, p } };

            // b^(ng-f)

            long cnt = ng - f;

            var c = Pow(b, cnt);

            var dd = Mul(a, c)[0][2];

            ans *= power(p, cnt);
            ans %= M;
            ans += dd;
            ans %= M;


            p *= 10;
            p %= M;
            f = ng;
        }

        Console.WriteLine(ans);
    }

    long power(long x, long y)
    {
        long res = 1;
        while (y > 0)
        {
            if (y % 2 == 1)
            {
                res *= x;
                res %= M;
            }
            x *= x;
            x %= M;
            y /= 2;
        }
        return res;
    }

    long[][] Mul(long[][] l, long[][] r)
    {
        long[][] res = new long[l.Length][];
        for (int i = 0; i < l.Length; i++)
        {
            res[i] = new long[r[0].Length];
            for (int k = 0; k < r[0].Length; k++)
            {
                for (int j = 0; j < l[0].Length; j++)
                {
                    res[i][k] += l[i][j] * r[j][k];
                    res[i][k] %= M;
                }
            }
        }
        return res;
    }

    long[][] Pow(long[][] m, long n)
    {
        var res = new long[3][] { new long[] { 1, 0, 0 }, new long[] { 0, 1, 0 }, new long[] { 0, 0, 1 } };

        while (n > 0)
        {
            if (n % 2 == 1)
            {
                res = Mul(res, m);
            }

            m = Mul(m, m);
            n /= 2;
        }

        return res;
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 13268