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

long long mod;

template<class Numeric> class Matrix {
    protected:
        vector< vector<Numeric> > _mat;
        int _col, _row;
        const bool usingModulo = true;
        void resize(int col, int row) {
            _col = col; _row = row;
            _mat.assign(col, vector<Numeric>(row, 0));
        }
    public:
        Numeric modulo = 1000000007; // using modulo
        Matrix(int col, int row) : _col(col), _row(row) {
            _mat.assign(col, vector<Numeric>(row, 0));
        }
        Matrix(int col, int row, int num) : _col(col), _row(row) {
            _mat.assign(col, vector<Numeric>(row, num));
        }
        int col() const { return _col; }
        int row() const { return _row; }
        vector<vector<Numeric>> mat() const {return _mat; }
        vector<Numeric> &operator[](int i) { return _mat[i]; }
        Numeric &operator() (int i, int j) { return _mat[i][j]; }
        Matrix<Numeric> &operator=(Matrix<Numeric> x) {
            this->_mat = x.mat();
            return *this;
        }
        Matrix<Numeric> operator+(Matrix<Numeric> &x) {
            if (this->col() != x.col() || this->row() != x.row()) {
                cout << "matrices are different sizes .. ";
                this->size(false); cout << "+"; x.size(true);
                exit(0);
            }
            Matrix<Numeric> ret(this->col(), this->row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    ret[i][j] = _mat[i][j] + x[i][j];
                    if (usingModulo) ret[i][j] %= modulo;
                }
            }
            return ret;
        }
        Matrix<Numeric> &operator+=(Matrix<Numeric> &x) {
            if (this->col() != x.col() || this->row() != x.row()) {
                cout << "matrices are different sizes .. ";
                this->size(false); cout << "+"; x.size(true);
                exit(0);
            }
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    _mat[i][j] += x[i][j];
                    if (usingModulo) _mat[i][j] %= modulo;
                }
            }
            return *this;
        }
        Matrix<Numeric> operator-(Matrix<Numeric> &x) {
            if (this->col() != x.col() || this->row() != x.row()) {
                cout << "matrices are different sizes .. ";
                this->size(false); cout << "-"; x.size(true);
                exit(0);
            }
            Matrix<Numeric> ret(this->col(), this->row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    ret[i][j] = _mat[i][j] - x[i][j];
                    if (usingModulo) ret[i][j] %= modulo;
                }
            }
            return ret;
        }
        Matrix<Numeric> &operator-=(Matrix<Numeric> &x) {
            if (this->col() != x.col() || this->row() != x.row()) {
                cout << "matrices are different sizes .. ";
                this->size(false); cout << "-"; x.size(true);
                exit(0);
            }
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    _mat[i][j] -= x[i][j];
                    if (usingModulo) _mat[i][j] %= modulo;
                }
            }
            return *this;
        }
        Matrix<Numeric> operator*(Matrix<Numeric> &x) {
            if (this->row() != x.col()) {
                cout << "cannot multiply matrices .. ";
                this->size(false); cout << "*"; x.size(true);
                exit(0);
            }
            Matrix<Numeric> ret(this->col(), x.row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < x.row(); ++j) {
                    for (int k = 0; k < this->row(); ++k) {
                        ret[i][j] += _mat[i][k] * x[k][j];
                        if (usingModulo) ret[i][j] %= modulo;
                    }
                }
            }
            return ret;
        }
        Matrix<Numeric> &operator*(Numeric k) {
            Matrix<Numeric> ret(this->col(), this->row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    ret(i, j) = _mat[i][j] * k;
                    if (usingModulo) ret(i, j) %= modulo;
                }
            }
            return ret;
        }
        Matrix<Numeric> &operator*=(Matrix<Numeric> &x) {
            if (this->row() != x.col()) {
                cout << "cannot multiply matrices .. ";
                this->size(false); cout << "*"; x.size(true);
                exit(0);
            }
            Matrix<Numeric> ret(this->col(), x.row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < x.row(); ++j) {
                    for (int k = 0; k < this->row(); ++k) {
                        ret[i][j] += _mat[i][k] * x[k][j];
                        if (usingModulo) ret[i][j] %= modulo;
                    }
                }
            }
            this->resize(this->col(), x.row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < x.row(); ++j) {
                    _mat[i][j] = ret[i][j];
                }
            }
            return *this;
        }
        Matrix<Numeric> &operator*=(Numeric k) {
            Matrix<Numeric> ret(this->col(), this->row());
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    _mat[i][j] *= k;
                    if (usingModulo) _mat %= modulo;
                }
            }
            return *this;
        }
        Numeric sum() {
            Numeric ret = 0;
            for (int i = 0; i < this->col(); ++i) {
                for (int j = 0; j < this->row(); ++j) {
                    ret += _mat[i][j];
                    if (usingModulo) ret %= modulo;
                }
            }
            return ret;
        }
        void print() {
            cout << "-- print "; this->size(false); cout << " --" << endl;
            for (int i = 0; i < _col; ++i) {
                for (int j = 0; j < _row; ++j) {
                    if (j != 0) cout << "\t";
                    cout << _mat[i][j];
                }
                cout << endl;
            }
            cout << "------------------" << endl;
        }
        void print(string str) {
            cout << "-- print \"" << str << "\" "; this->size(false); cout << " --" << endl;
            for (int i = 0; i < _col; ++i) {
                for (int j = 0; j < _row; ++j) {
                    if (j != 0) cout << "\t";
                    cout << _mat[i][j];
                }
                cout << endl;
            }
            cout << "------------------" << endl;
        }
        void size (bool endline = true) const {
            cout << "(" << this->col() << ", " << this->row() << ")";
            if (endline) cout << endl;
        }
};

long long modpow(int n, int r) {
    long long ret = 1;
    long long tmp = (long long)n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp;
        tmp %= mod;
        ret %= mod;
        r /= 2;
    }
    return ret;
}

int main() {
    long long l, a, b, m; cin >> l >> a >> b >> m;
    mod = m;
    vector<long long> v[19], bb[19], tmpbb[19];
    vector<long long> c(19, 1);
    for (int i = 0; i < 18; i++) {
        c[i+1] = c[i] * 10;
    }
    long long st = a; long long en = a + b * (l-1);
    //cout << "  " << st << " " << en << endl;
    long long ans = 0; long long sum = 0;
    for (int k = 1; k < 19; k++) {
        if (c[k] <= st) continue;
        if (en < c[k-1]) continue;
        long long stk = max(st, (c[k-1] - a + b - 1) / b * b + a);
        long long enk = min(en, (c[k] - 1 - a) / b * b + a);
        long long lk = (enk - stk) / b + 1;
        sum += lk;
        Matrix<long long> u(3, 3, 0); u.modulo = m;
        u[0][0] = u[1][0] = u[1][1] = u[2][1] = 1;
        u[2][2] = modpow(10, k);
        Matrix<long long> s(3, 1, 0); s.modulo = m;
        s[0][0] = b % mod; s[1][0] = stk % mod; s[2][0] = ans;
        while (lk) {
            if (lk & 1) s = u * s;
            lk /= 2; u = u * u;
        }
        ans = s[2][0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256