#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

//const ll mod = 1e9 + 7;
const ll M = 18;
ll mod;
struct Mat
{
    ll m[3][3];
    Mat(ll v)
    {
        memset(m, 0, sizeof m);
        for(ll i = 0; i < 3; i++)
            m[i][i] = v;
    }

    Mat operator* (const Mat &a) const
    {
        Mat r(0);
        for(ll i = 0; i < 3; i++)
        {
            for(ll j = 0; j < 3; j++)
            {
                for(ll k = 0; k < 3; k++)
                {
                    r.m[i][j] = (r.m[i][j] + m[i][k] * 1ll * a.m[k][j]) % mod;
                }
            }
        }
        return r;
    }
};

ll modexp(Mat a, ll b, ll s)
{
    Mat r(1);
    while(b)
    {
        if(b & 1) r = r * a;
        a = a * a;
        b >>= 1;
    }
    return (s * 1ll * r.m[0][1] + r.m[0][2]) % mod;
}

ll modexp(ll a, ll b)
{
    ll r = 1;
    while(b)
    {
        if(b & 1) r = (r * 1ll * a) % mod;
        a = (a * 1ll * a) % mod;
        b >>= 1;
    }
    return r;
}

ll t[M+1];

ll BS(ll n, ll a, ll b, ll lmt)
{
    ll l = -1, r = n;

    while(l != r)
    {
        ll mid = (l + r + 1) >> 1;
        if(a + mid * b < lmt) l = mid;
        else r = mid - 1;
    }
    return l;
}
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    ll l, a, b, t1 = 1;
    ll ans = 0;
    cin >> l >> a >> b >> mod;
    t[0] = -1;
    for(ll i = 1; i <= M; i++)
    {
        t1 *= 10;
        t[i] = BS(l - 1, a, b, t1);
        ll A = a + (t[i - 1] + 1) * b;
        ll n = t[i] - t[i - 1];

        if(n)
        {
            Mat a(1);
            a.m[0][0] = t1 % mod;
            a.m[0][1] = 1;
            a.m[1][2] = b % mod;

            ll r = modexp(a, n, A % mod);
            ll x = modexp(t1 % mod, n);
            ans = (ans * 1ll * x + r) % mod;
        }
    }
    cout << ans << endl;

    //double end_time = clock();
    //prllf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}
