#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
// constexpr lnt MOD = 1e9+7;

lnt MOD = 1e9+7;

struct mint {
	long long num;
	mint(long long a = 0) : num((a%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-num); }
	mint &operator+= (const mint &a) {
		if((num += a.num) >= MOD) num -= MOD;
		return *this;
	}
	mint &operator-= (const mint &a) {
		if((num += MOD-a.num) >= MOD) num -= MOD;
		return *this;
	}
	mint &operator*= (const mint &a) {
		(num *= a.num) %= MOD;
		return *this;
	}
	mint operator+ (const mint &a) const { return mint(*this) += a; }
	mint operator- (const mint &a) const { return mint(*this) -= a; }
	mint operator* (const mint &a) const { return mint(*this) *= a; }

	inline bool operator== (const mint &a) const { return num == a.num; }
	inline bool operator!= (const mint &a) const { return num != a.num; }

	mint pow(long long n) const {
		mint ret(1), mul(num);
		while(n > 0){
			if(n & 1) ret *= mul;
			mul *= mul;
			n >>= 1ll;
		}
		return ret;
	}

	// for prime MOD	
	mint inverse() const {
		long long a = num, b = MOD, u = 1, v = 0, t;
		while(b > 0){
			t = a/b;
			swap(a -= t*b, b);
			swap(u -= t*v, v);
		}
		return mint(u);
	}
	mint &operator/= (const mint &a) {
		(*this) *= a.inverse();
		return *this;
	}
	mint operator/ (const mint &a) const { return mint(*this) /= a; }
};

template<class T> struct Matrix {
	vector<vector<T>> A;
	Matrix() {}
	Matrix(size_t n, size_t m) : A(n, vector<T>(m, 0)) {};

	static Matrix I(size_t n) {
		Matrix mat(n, n);
		for(size_t i = 0; i < n; i++) mat[i][i] = 1;
		return (mat);
	}

	size_t height() const { return (A.size()); }
	size_t width() const { return (A[0].size()); }

	inline const vector<T> &operator[](int k) const { return (A.at(k)); }
	inline vector<T> &operator[](int k) { return (A.at(k)); }

	Matrix &operator+= (const Matrix &B){
		size_t n = height(), m = width();
		assert(n == B.height() and m == B.width());
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				(*this)[i][j] += B[i][j];
			}
		}
		return (*this);
	}
	Matrix &operator-= (const Matrix &B){
		size_t n = height(), m = width();
		assert(n == B.height() and m == B.width());
		for(size_t i = 0; i < n; i++)
			for(size_t j = 0; j < m; j++)
				(*this)[i][j] -= B[i][j];
		return (*this);
	}
	Matrix &operator*= (const Matrix &B){
		size_t n = height(), m = B.width(), p = width();
		assert(p == B.height());
		vector<vector<T>> C(n, vector<T>(m, 0));
		for(size_t i = 0; i < n; i++)
			for(size_t j = 0; j < m; j++)
				for(size_t k = 0; k < p; k++)
					C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]);
		A.swap(C);
		return (*this);
	}
	Matrix &operator^= (long long p){
		Matrix B = Matrix::I(height());
		while(p > 0){
			if(p & 1) B *= (*this);
			(*this) *= (*this);
			p >>= 1ll;
		}
		A.swap(B.A);
		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 p) const { return (Matrix(*this) ^= p); }
};

int main(){
	summon_tourist;

	lnt L, A, B, M; cin >> L >> A >> B >> M;
	MOD = M;

	lnt last = A+(L-1)*B;

	// cerr << last << ln;
	lnt S = A;
	Matrix<mint> mat(1, 3);
	mat[0] = {0ll, A, 1ll};
	for(lnt d = lnt(to_string(A).size()); d <= lnt(to_string(last).size()); d++){
		lnt ei, cnt;
		if(to_string(S).size() != d) continue;
		if(d == lnt(to_string(last).size())) ei = last;
		else ei = S + ((lnt)powl(10, d) - 1 - S)/B*B;
		cnt = (ei-S) / B + 1;

		// cerr << S << ' ' << ei << ' ' << B << ' ' << cnt << ln;
 
		Matrix<mint> mul(3, 3);
		mul[0] = {(lnt)powl(10, d), 0ll, 0ll};
		mul[1] = {1ll, 1ll, 0ll};
		mul[2] = {0ll, B, 1ll};
		mul ^= cnt;
		mat *= mul;

		S = ei + B;
	}
	cout << mat[0][0].num << ln;
	// cerr << S << ln;
}

Measured memory_bytes: 3784