#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 998244353LL;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
class modint {
    using u64 = std::uint_fast64_t;
    static u64 &mod() {
        static u64 mod_ = 0;
        return mod_;
    }

  public:
    u64 a;
    modint(const u64 x = 0) noexcept : a(x % getmod()) {}
    u64 &value() noexcept { return a; }
    modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= getmod()) {
            a -= getmod();
        }
        return *this;
    }
    modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += getmod();
        }
        a -= rhs.a;
        return *this;
    }
    modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % getmod();
        return *this;
    }
    modint &operator/=(modint rhs) noexcept {
        u64 exp = getmod() - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    static void setmod(const u64 x) { mod() = x; }
    static u64 getmod() { return mod(); }
    friend ostream &operator<<(ostream &os, const modint &x) {
        os << x.a;
        return os;
    }
    friend istream &operator>>(istream &is, modint &x) {
        is >> x.a;
        return is;
    }
};
using mint = modint;
template <class T>
struct Matrix {
    vector<vector<T>> a;
    Matrix() {}
    Matrix(int n, int m) : a(n, vector<T>(m)) {}
    inline const vector<T> &operator[](int k) const {
        return a.at(k);
    }
    inline vector<T> &operator[](int k) {
        return a.at(k);
    }
    Matrix I(int n) {
        Matrix mat(n, n);
        for (int i = 0; i < n; i++) {
            mat[i][i] = 1;
        }
        return mat;
    }
    Matrix &operator+=(const Matrix &rhs) {
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < a[i].size(); j++) {
                (*this)[i][j] += rhs[i][j];
            }
        }
        return (*this);
    }
    Matrix &operator-=(const Matrix &rhs) {
        for (int i = 0; i < a.size(); i++) {
            for (int j = 0; j < a[i].size(); j++) {
                (*this)[i][j] -= rhs[i][j];
            }
        }
        return (*this);
    }
    Matrix &operator*=(const Matrix &rhs) {
        int n = a.size(), m = a[0].size(), p = rhs[0].size();
        assert(m == rhs.a.size());
        vector<vector<T>> b(n, vector<T>(p));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < p; j++) {
                for (int k = 0; k < m; k++) {
                    b[i][j] += (*this)[i][k] * rhs[k][j];
                }
            }
        }
        swap(a, b);
        return (*this);
    }
    Matrix &operator^=(const long long &rhs) {
        long long n = rhs;
        Matrix res = Matrix::I(a.size());
        while (n > 0) {
            if (n & 1) {
                res *= (*this);
            }
            (*this) *= (*this);
            n >>= 1;
        }
        swap(a, res.a);
        return (*this);
    }
    Matrix operator+(const Matrix &rhs) const {
        return Matrix(*this) += rhs;
    }
    Matrix operator-(const Matrix &rhs) const {
        return Matrix(*this) -= rhs;
    }
    Matrix operator*(const Matrix &rhs) const {
        return Matrix(*this) *= rhs;
    }
    Matrix operator^(const long long &rhs) const {
        return Matrix(*this) ^= rhs;
    }
};
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    V<ll> di(19);
    di[0] = 1;
    for (int i = 1; i <= 18; i++) {
        di[i] = di[i - 1] * 10LL;
    }
    ll n, a, b, m;
    cin >> n >> a >> b >> m;
    modint::setmod(m);
    mint res = 0;
    ll sum = 0;
    for (ll d = 17; d >= 0; d--) {
        if (a + b * (n - 1) < di[d] || di[d + 1] <= a) continue;
        ll ok = n - 1, ng = -1;
        while (ok - ng > 1) {
            ll mid = (ok + ng) / 2;
            if (di[d] <= a + b * mid) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ll l = ok;
        ok = 0, ng = n;
        while (ng - ok > 1) {
            ll mid = (ok + ng) / 2;
            if (a + b * mid < di[d + 1]) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ll r = ok;
        if (l > r) continue;
        Matrix<mint> a0(3, 1), x(3, 3);
        a0[1][0] = a + b * r;
        a0[2][0] = di[d + 1];
        x[0][0] = 1, x[0][1] = 1;
        x[1][1] = di[d + 1], x[1][2] = m - b % m;
        x[2][2] = di[d + 1];
        x ^= (r - l);
        x *= a0;
        mint s = (x[0][0] + x[1][0]) * (mint(10) ^ sum);
        res += s;
        sum += (d + 1) * (r - l + 1);
    }
    cout << res << '\n';
}

Measured memory_bytes: 256