#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int MOD;
struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend istream& operator >> (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }

    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

    modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; }
    modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; }
    modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; }
    modnum operator - () { modnum res; if (v) res.v = MOD - v; return res; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }

    modnum pow(ll e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    modnum inv() const {
        int g = MOD, x = 0, y = 1;
        for (int r = v; r != 0; ) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        assert(g == 1);
        assert(y == MOD || y == -MOD);
        return x < 0 ? x + MOD : x;
    }
    modnum& operator /= (const modnum& o) { return (*this) *= o.inv(); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }

    static modnum fact(int n) {
        static vector<modnum> fact = { 1 };
        while (fact.size() <= n)
            fact.push_back(fact.back() * fact.size());
        return fact[n];
    }
    static modnum ncr(int n, int r) {
        if (r < 0 || n < r) return 0;
        return fact(n) / (fact(r) * fact(n - r));
    }
};
using mn = modnum;

template<typename T> struct matrix {
    int N;
    vector<T> dat;

    matrix<T> (int _N, T fill = T(0), T diag = T(0)) : N(_N) {
        dat.resize(N * N, fill);
        for (int i = 0; i < N; i++)
            (*this)(i, i) = diag;
    }

    T& operator()(int i, int j) {
        return dat[N * i + j];
    }
    T operator()(int i, int j) const {
        return dat[N * i + j];
    }

    matrix<T> operator *(const matrix<T>& b) const {
        matrix<T> r(N);
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                for (int k = 0; k < N; k++)
                    r(i, j) += (*this)(i, k) * b(k, j);
        return r;
    }

    matrix<T> pow(ll e) const {
        if(!e) return matrix<T>(N, 0, 1);
        if (e&1) return *this * this->pow(e - 1);
        return (*this * *this).pow(e/2);
    }

    int rank() const {
        matrix<T> m = *this;
        int r = 0;
        for (int i = 0; i < N; i++) {
            for (int j = r; j < N; j++) {
                if (m(j, i) != T(0)) {
                    for (int k = 0; k < N; k++)
                        swap(m(r, k), m(j, k));
                    break;
                }
            }
            if (m(r, i) == T(0)) continue;
            for (int j = 0; j < N; j++) {
                if (j == r) continue;
                T c = m(j, i) / m(r, i);
                for (int k = 0; k < N; k++)
                    m(j, k) -= c * m(r, k);
            }
            r++;
        }
        return r;
    }

    friend ostream& operator<<(ostream& os, const matrix<T>& m) {
        os << "{";
        for (int i = 0; i < m.N; i++) {
            if(i) os << "},\n ";
            os << "{";
            for (int j = 0; j < m.N; j++) {
                if(j) os << ", ";
                os << setw(10) << m(i, j) << setw(0);
            }
        }
        return os << "}}";
    }
};

ll prod(ll a, ll b, ll m) {
    return (a % m) * (b % m) % m;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    ll L, A, B;
    cin >> L >> A >> B >> MOD;

    vector<mn> contr(19);

    ll lb = 1, ub = 10;
    for (int dc = 1; dc <= 18; dc++) {
        if (dc > 1) { lb *= 10, ub *= 10; }
        if (A >= ub) continue;

        ll fi = max(0ll, (lb - A + B - 1) / B);
        ll li = min(L, (ub - A + B - 1) / B);

        if (fi < li) {
            mn shift = mn(10).pow(dc).pow(li - fi);
            for (int pd = 1; pd < dc; pd++)
                contr[pd] *= shift;

            matrix<mn> mat(3);
            mat(0, 0) = mn(10).pow(dc);
            mat(1, 0) = 1;
            mat(1, 1) = 1;
            mat(2, 1) = mn(B);
            mat(2, 2) = 1;

            mn t1 = mn(A) + fi * mn(B);

            mat = mat.pow(li - fi);
            contr[dc] = t1 * mat(1, 0) + mat(2, 0);
        }
    }

    mn ans = 0;
    for (mn v : contr)
        ans += v;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256