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

//F

long long l,a,b,mod,d[20]={0},c;
int i;

long long powmod(long long x, long long y){
	if(y==0) return 1;
	else if(y%2==0) return powmod((x*x)%mod,y/2);
	else return (powmod(x,y-1)*x)%mod;
}

long long mypow(long long x, long long y){
	if(y==0) return 1;
	else if(y%2==0) return mypow((x*x),y/2);
	else return (mypow(x,y-1)*x);
}

array<long long,9> matprod(array<long long,9> p,array<long long,9> q){
	array<long long,9> r;
	r[0]=(p[0]*q[0]%mod+p[1]*q[3]%mod+p[2]*q[6]%mod)%mod;
	r[1]=(p[0]*q[1]%mod+p[1]*q[4]%mod+p[2]*q[7]%mod)%mod;
	r[2]=(p[0]*q[2]%mod+p[1]*q[5]%mod+p[2]*q[8]%mod)%mod;
	r[3]=(p[3]*q[0]%mod+p[4]*q[3]%mod+p[5]*q[6]%mod)%mod;
	r[4]=(p[3]*q[1]%mod+p[4]*q[4]%mod+p[5]*q[7]%mod)%mod;
	r[5]=(p[3]*q[2]%mod+p[4]*q[5]%mod+p[5]*q[8]%mod)%mod;
	r[6]=(p[6]*q[0]%mod+p[7]*q[3]%mod+p[8]*q[6]%mod)%mod;
	r[7]=(p[6]*q[1]%mod+p[7]*q[4]%mod+p[8]*q[7]%mod)%mod;
	r[8]=(p[6]*q[2]%mod+p[7]*q[5]%mod+p[8]*q[8]%mod)%mod;
	return r;
}

array<long long,9> matpow(array<long long,9> p,long long x){
	if(x==0) return {1,0,0,0,1,0,0,0,1};
	if(x%2==0) return matpow(matprod(p,p),x/2);
	else return matprod(matpow(p,x-1),p);
}

int main() {
	// your code goes here
	cin >> l >> a >> b >> mod;
	for(i=1;i<=18;i++){
		if(mypow(10,i)<a) d[i]=0;
		else{
			d[i]=((mypow(10,i)-1-a)-(mypow(10,i)-1-a)%b)/b+1;
		}
		d[i]=min(d[i],l);
	}
	array<long long,9> ans={1,0,0,0,1,0,0,0,1},mx;
	for(i=1;i<=18;i++){
		c=d[i]-min(d[i],d[i-1]);
		mx={powmod(10,i),0,0,1,1,0,0,b%mod,1};
		ans=matprod(ans,matpow(mx,c));
	}
	mx={0,a%mod,1,0,0,0,0,0,0};
	ans=matprod(mx,ans);
	cout << ans[0] << endl;
	return 0;
}