#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

class Fp {
public:
    ll val;

private:
    inline void calc_mod(ll &v) {
        if (v >= mod)
            v -= mod;
    }

public:
    Fp() {}
    Fp(ll v) : val(v % mod) {
        if (val < 0)
            val += mod;
    }
    Fp operator+=(const Fp &in) {
        val += in.val;
        calc_mod(val);
        return *this;
    }
    Fp operator+(const Fp &in) const {
        return Fp(*this) += in;
    }
    Fp &operator-=(const Fp &in) {
        val -= in.val;
        calc_mod(val);
        if (val < 0)
            val += mod;
        return *this;
    }
    Fp operator-(const Fp &in) const {
        return Fp(*this) -= in;
    }
    Fp &operator*=(const Fp &in) {
        val = val * in.val % mod;
        return *this;
    }
    Fp operator*(const Fp &in) const {
        return Fp(*this) *= in;
    }
    Fp &operator/=(const Fp &in) {
        *this *= modpow(in, mod - 2);
        return *this;
    }
    Fp operator/(const Fp &in) const {
        return Fp(*this) /= in;
    }
    bool operator==(const Fp &in) const {
        return val == in.val;
    }
    bool operator!=(const Fp &in) const {
        return val != in.val;
    }
    friend Fp modpow(const Fp &in, ll n) {
        if (n == 0)
            return 1;
        if (n & 1) {
            return in * modpow(in * in, n / 2);
        } else {
            return modpow(in * in, n / 2);
        }
    }
};
using modll = Fp;
class Factorial {
public:
    vector<modll> fact, finv;
    Factorial(ll n) : fact(n + 1, modll(1)), finv(n + 1, modll(1)) {
        for (int i = 2; i <= n; i++) {
            modll tmp(i);
            fact[i] = fact[i - 1] * tmp;
            finv[i] = finv[i - 1] / tmp;
        }
    }
    modll com(const ll &n, const ll &k) {
        if (n < k || n < 0 || k < 0)
            return modll(0);
        return fact[n] * finv[k] * finv[n - k];
    }
};

template <typename T>
class SquareMatrix {
public:
    int size;
    vector<T> e;

public:
    SquareMatrix() {}
    SquareMatrix(int n) : size(n), e(size * size, 0) {}

    T &elem(int row, int col) {
        assert(0 <= row && row < size && 0 <= col && col < size);
        return e[size * row + col];
    }

    const T &_elem(int row, int col) const {
        return e[size * row + col];
    }

    const SquareMatrix unitmat() const {
        SquareMatrix um(size);
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                if (i == j) {
                    um.elem(i, j) = 1;
                }
            }
        }
        return um;
    }

    SquareMatrix &operator=(const SquareMatrix &in) {
        assert(in.size == size);
        for (int i = 0; i < size * size; i++) {
            e[i] = in.e[i];
        }
        return *this;
    }

    SquareMatrix &operator+=(const SquareMatrix &in) {
        assert(in.size == size);
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                elem(i, j) += in._elem(i, j);
            }
        }
        return *this;
    }

    SquareMatrix operator+(const SquareMatrix &in) const {
        return SquareMatrix(*this) += in;
    }

    SquareMatrix &operator-=(const SquareMatrix &in) {
        assert(in.size == size);
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                elem(i, j) -= in._elem(i, j);
            }
        }
        return *this;
    }

    SquareMatrix operator-(const SquareMatrix &in) const {
        return SquareMatrix(*this) -= in;
    }

    SquareMatrix &operator*=(const SquareMatrix &in) {
        assert(in.size == size);
        SquareMatrix tmp(size);
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                for (int k = 0; k < size; k++) {
                    tmp.elem(i, j) += _elem(i, k) * in._elem(k, j);
                }
            }
        }
        *this = tmp;
        return *this;
    }

    SquareMatrix operator*(const SquareMatrix &in) const {
        assert(in.size == size);
        SquareMatrix tmp(size);
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                for (int k = 0; k < size; k++) {
                    tmp.elem(i, j) += _elem(i, k) * in._elem(k, j);
                }
            }
        }
        return tmp;
    }

    SquareMatrix &operator*=(const T &k) {
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                elem(i, j) *= k;
            }
        }
        return *this;
    }

    SquareMatrix operator*(const T &k) const {
        return SquareMatrix(*this) *= k;
    }

    friend SquareMatrix matpow(const SquareMatrix &in, ll n) {
        if (n == 0)
            return in.unitmat();
        if (n & 1) {
            return in * matpow(in * in, n / 2);
        } else {
            return matpow(in * in, n / 2);
        }
    }
};

template <typename T>
SquareMatrix<T> operator*(const T &k, SquareMatrix<T> mat) {
    return SquareMatrix<T>(mat) *= k;
}

ll getdigit(ll n) {
    int res = 0;
    while (n > 0) {
        n /= 10;
        res++;
    }
    return res;
}

ll intpow(const ll &a, const ll &n) {
    if (n == 0)
        return 1;
    else if (n & 1)
        return intpow(a * a, n / 2) * a;
    else
        return intpow(a * a, n / 2);
}

signed main() {
    cin >> L >> A >> B >> M;
    mod = M;
    int mnd = getdigit(A);
    int mxd = getdigit(A + (L - 1) * B);
    ll first = A;
    SquareMatrix<modll> ansmat(3);
    ansmat = ansmat.unitmat();

    for (int i = mnd; i <= mxd; i++) {
        if (getdigit(first) != i)
            continue;
        ll n;
        if (i == mxd) {
            n = (A + (L - 1) * B - first) / B + 1;
        } else {
            n = (intpow(10, i) - 1 - first) / B + 1;
        }
        SquareMatrix<modll> mat(3);
        mat.elem(0, 0) = modpow(modll(10), i);
        mat.elem(1, 0) = 1;
        mat.elem(1, 1) = 1;
        mat.elem(2, 1) = B;
        mat.elem(2, 2) = 1;
        ansmat *= matpow(mat, n);
        first += B * n;
    }
    modll ans = modll(A) * ansmat.elem(1, 0) + ansmat.elem(2, 0);
    cout << ans.val << endl;
}

Measured memory_bytes: 256