#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
//constexpr long long MOD = 1000000007LL;
constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

//modint::set(M)
struct modint {
    using u64 = std::uint_fast64_t;

    public:
    u64 a;

    modint(u64 x = 0) : a(x >= 0 ? x%Modulus() : (Modulus() - (-x)%Modulus()) % Modulus()) {}

    static u64 &Modulus() {static u64 Modulus = 0; return Modulus;}
    static void set (u64 M) {Modulus() = M;}

    modint operator+(const modint rhs) const {return modint(*this) += rhs;}
    modint operator-(const modint rhs) const {return modint(*this) -= rhs;}
    modint operator*(const modint rhs) const {return modint(*this) *= rhs;}
    modint operator/(const modint rhs) const {return modint(*this) /= rhs;}

    modint &operator+=(const modint rhs) {
        a += rhs.a;
        if (a >= Modulus()) {
            a -= Modulus();
        }
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if (a < rhs.a) {
            a += Modulus();
        }
        a -= rhs.a;
        return *this;
    }
    modint &operator*=(modint rhs) {
        a = a * rhs.a % Modulus();
        return *this;
    }
    modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus() - 2;
        while (exp) {
        if (exp % 2) {
            *this *= rhs;
        }
        rhs *= rhs;
        exp /= 2;
        }
        return *this;
    }
};

using mint = modint;

const int sz = 3;
template<typename T>
struct Matrix {
   	array<array<T, sz>, sz> A;
	int N;

   	Matrix() : N(sz) {}
   	Matrix(int N) : N(N) {}

	inline const array<T, sz> &operator[](int k) const {return A[k];}
  	inline array<T, sz> &operator[](int k) {return A[k];}

  	static Matrix I(int N) {
    	Matrix<T> mat(N);
    	for(int i = 0; i < N; ++i) mat[i][i] = 1;
    	return mat;
  	}

  	Matrix &operator+=(const Matrix &B) {
    	for(int i = 0; i < N; ++i) {
      	    for(int j = 0; j < N; ++j) {
        	    (*this)[i][j] += B[i][j];
            }
        }
    	return (*this);
  	}

  	Matrix &operator-=(const Matrix &B) {
    	for(int i = 0; i < N; ++i) {
      		for(int j = 0; j < N; ++j) {
				(*this)[i][j] -= B[i][j];
			}
		}
    	return (*this);
  	}

    Matrix &operator*=(const Matrix &B) {
        Matrix<T> C(N);
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N; ++j) {
                for(int k = 0; k < N; ++k) {
                    C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]);
                }
            }
        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                swap(A[i][j],C.A[i][j]);
            }
        }
        return *this;
    }

    Matrix &operator^=(long long k) {
        Matrix<T> B = Matrix<T>::I(N);
        while(k > 0) {
            if(k & 1) B *= *this;
            *this *= *this;
            k >>= 1LL;
        }
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                swap(A[i][j],B.A[i][j]);
            }
        }
        return *this;
    }

    Matrix operator+(const Matrix &B) const {return (Matrix(*this) += B);}
    Matrix operator-(const Matrix &B) const {return (Matrix(*this) -= B);}
    Matrix operator*(const Matrix &B) const {return (Matrix(*this) *= B);}
    Matrix operator^(const long long k) const {return (Matrix(*this) ^= k);}
};

ll keta[20];
ll cnt[20];
ll s[20];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	ll L,A,B,M; cin >> L >> A >> B >> M;
	modint::set(M);

	ll a = A;
	ll b = 10;
	ll LL = L;
	for (int i = 1; i <= 18; i++) {
		if (a < b) {
			s[i] = a;
			cnt[i] = min(LL,(b-a-1)/B+1);
			LL -= cnt[i];
			a += cnt[i]*B;
			if (LL==0) break;
		}
		b *= 10;
	}
	//for (int i = 1; i <= 18; i++) cout << s[i] << " ";
	//cout << ln;
	mint bb = 1;
	bb *= 10;
	vector<mint> V(20);
	for (int i = 1; i <= 18; i++) {
		if (cnt[i]) {
			Matrix<mint> mat(3);
			mat[0][0] = bb;
			mat[0][1] = mat[1][1] = mat[1][2] = mat[2][2] = 1;
			mat[0][2] = mat[1][0] = mat[2][0] = mat[2][1] = 0;
			mat ^= cnt[i];
			V[i] = mat[0][1]*s[i] + mat[0][2]*B;
		}
		bb *= 10;
	}
	mint ans = 0;
	for (int i = 1; i <= 18; i++) {
		if (cnt[i]) {
			ll k = cnt[i];
			mint c = 1;
			mint p = 1;
			p *= 10;
			while (k > 0) {
				if (k&1) c *= p;
				k >>= 1;
				p *= p;
			}
			rep(j,i) ans *= c;
			ans += V[i];
		}
	}

	cout << ans.a << ln;
}


Measured memory_bytes: 256