#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

typedef vector<ll>vec;
typedef vector<vec>mat;

ll L,A,B,MOD;

mat mul(mat&a, mat&b) {
	mat c(a.size(), vec(b[0].size()));
	rep(i, a.size())rep(j, b[0].size())rep(k, b.size())
		(c[i][j] += a[i][k] * b[k][j]) %= MOD;
	return c;
}
mat ppow(mat&a, ll b) {
	mat res(a.size(), vec(a.size()));
	rep(i, a.size())res[i][i] = 1;
	while (b) {
		if (b & 1)res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}

ll lb(ll x){
	ll ok=L,ng=-1;
	while(ok-ng>1){
		ll t=(ok+ng)/2;
		if(A+B*t>=x)ok=t;
		else ng=t;
	}
	return ok;
}

int main(){
	cin>>L>>A>>B>>MOD;
	ll d=1;
	ll ans=0;
	for(ll i=1;i<=18;i++){
		ll l=lb(d),r=lb(d*10);
		(ans*=ppow(d*10,(r-l)))%=MOD;
		ll s=(A+B%MOD*l)%MOD;
		mat M1{{d*10%MOD,1,0},{0,1,1},{0,0,1}};
		mat M2{{0},{s},{B%MOD}};
		mat res=ppow(M1,r-l);
		M2=mul(res,M2);
		(ans+=M2[0][0])%=MOD;
		d*=10;
	}
	cout<<ans<<endl;
}