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

using lint = int64_t;
lint mod;

// template <int64_t mod>
class ModInt {
    int64_t val;
    public:
    ModInt(): val(0) {}
    ModInt(int64_t init_val): val(init_val >= 0? init_val % mod: mod - (-init_val) % mod) {}

    bool operator !() {return val == 0;}
    bool operator == (const ModInt that) const {return val == that.val;}
    bool operator != (const ModInt that) const {return val != that.val;}
    
    ModInt operator ++() {val = (val + 1) % mod; return *this;}
    ModInt operator --() {val = ((val - 1) % mod + mod) % mod; return *this;}
    const ModInt operator ++(int) {
        ModInt tmp = *this; ++(*this); return tmp;
    }
    const ModInt operator --(int) {
        ModInt tmp = *this; --(*this); return tmp;
    }

    ModInt& operator += (const ModInt that) {val = (val + that.val) % mod; return *this;}
    ModInt& operator -= (const ModInt that) {val = ((val - that.val) % mod + mod) % mod; return *this;}
    ModInt& operator *= (const ModInt that) {val = (val * that.val) % mod; return *this;}
    ModInt& operator /= (const ModInt that) {
        int64_t res = 1, n = that.val, p = mod - 2;
        while (p > 0) {
            if (p % 2 == 1) res = res * n % mod;
            n = n * n % mod; p /= 2;
        }
        val = val * res % mod; return *this;
    }

    ModInt operator + (const ModInt that) const {return ModInt(*this) += that;}
    ModInt operator - (const ModInt that) const {return ModInt(*this) -= that;}
    ModInt operator * (const ModInt that) const {return ModInt(*this) *= that;}
    ModInt operator / (const ModInt that) const {return ModInt(*this) /= that;}

    friend istream& operator >> (istream& is, ModInt& inp) {
        int64_t init_val; is >> init_val; inp = ModInt(init_val); return is;
    }
    friend ostream& operator << (ostream& os, const ModInt& outp) {
        return os << outp.val;
    }
};

template <typename T, size_t n>
class Matrix {
    vector<vector<T>> val;
    public:
    Matrix(): val(n, vector<T>(n, 0)) {}
    Matrix(T init_val): val(n, vector<T>(n, 0)) {
        for (size_t i = 0; i < n; i++) val[i][i] = init_val;
    }

    vector<T>& operator [](size_t i) {return val[i];}

    Matrix& operator += (const Matrix that) {
        for (size_t i = 0; i < n; i++) for (size_t j = 0; j < n; j++) {val[i][j] += that.val[i][j];}
        return *this;
    }
    Matrix& operator -= (const Matrix that) {
        for (size_t i = 0; i < n; i++) for (size_t j = 0; j < n; j++) {val[i][j] -= that.val[i][j];}
        return *this;
    }
    Matrix& operator *= (const Matrix that) {
        Matrix tmp = *this;
        for (size_t i = 0; i < n; i++) for (size_t j = 0; j < n; j++) {
            val[i][j] = 0;
            for (size_t k = 0; k < n; k++) val[i][j] += tmp[i][k] * that.val[k][j];
        }
        return *this;
    }
    
    Matrix operator + (const Matrix that) const {return Matrix(*this) += that;}
    Matrix operator - (const Matrix that) const {return Matrix(*this) -= that;}
    Matrix operator * (const Matrix that) const {return Matrix(*this) *= that;}

    bool operator !() {return this == Matrix(0);}
    bool operator == (const Matrix that) const {return !(this - that);}
    bool operator != (const Matrix that) const {return !(this == that);}

    friend ostream& operator << (ostream& os, const Matrix& outp) {
        for (size_t i = 0; i < n; i++) {
            for (size_t j = 0; j < n; j++) os << outp.val[i][j] << ' '; if (i + 1 < n) os << endl;
        }
        return os;
    }
};

template <typename T, typename U>
T power(T n, U p) {
    T res = (T)1;
    while (p > 0) {
        if (p % 2 == 1) res *= n;
        n *= n; p /= 2;
    }
    return res;
}

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

int main() {
    lint l, a, b;
    cin >> l >> a >> b >> mod;
    lint pos = a;
    int init_d = num_digit(a);
    Matrix<ModInt, 3> mat_prod = (ModInt)1;

    for (int d = init_d; d <= 18 and l > 0; d++) {
        lint can = (power((lint)10, d) - pos + b - 1) / b;
        lint use = min(can, l);
        l -= use;
        pos += b * use;

        Matrix<ModInt, 3> mat;
        mat[0][0] = power((ModInt)10, d);
        mat[0][1] = 1;
        mat[1][1] = 1;
        mat[1][2] = b;
        mat[2][2] = 1;
        mat_prod = power(mat, use) * mat_prod;
    }

    ModInt ans = mat_prod[0][1] * a + mat_prod[0][2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384