#include <iostream>
#include <vector>

template <class T, class Int>
T ipow(T b, Int n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <class T>
using Vector = std::vector<T>;
template <class T>
using Matrix = Vector<Vector<T>>;

template <class T>
Matrix<T> operator*(const Matrix<T>& a, const Matrix<T>& b) {
    int n = a.size(), m = b.size(), l = b.front().size();
    Matrix<T> ret(n, Vector<T>(l, 0));

    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < l; ++k) {
            for (int j = 0; j < m; ++j) {
                ret[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    return ret;
}

template <class T, class Int>
Matrix<T> mpow(Matrix<T> b, Int n) {
    Matrix<T> ret(b.size(), Vector<T>(b.size(), 0));
    for (int i = 0; i < b.size(); ++i) ret[i][i] = 1;

    while (n > 0) {
        if (n & 1) ret = ret * b;
        n >>= 1;
        b = b * b;
    }
    return ret;
}

struct ModInt {
    using lint = long long;
    using mint = ModInt;

    int val;
    static int MOD;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

int ModInt::MOD;
using mint = ModInt;

using lint = long long;

int main() {
    lint l, a, b;
    std::cin >> l >> a >> b >> ModInt::MOD;

    auto ith = [&](lint x) {
        return (x <= a - b ? -1 : (x - a + b - 1) / b);
    };
    // x以上の最小の項

    mint ans = 0;
    for (int k = 1; k <= 18; ++k) {
        lint low = std::max(0LL, ith(ipow(10LL, k - 1))),
             high = std::min(l, ith(ipow(10LL, k)));
        // [low, high)項がk桁
        if (high < 0) continue;
        if (low > l) break;

        lint len = high - low;
        ans *= ipow(ipow(mint(10), k), len);

        Matrix<mint> mat{{ipow(mint(10), k), 1, 0},
                         {0, 1, b},
                         {0, 0, 1}};
        mat = mpow(mat, len);
        ans += mat[0][1] * (a + b * low) + mat[0][2];
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256