#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll L,A,B,M;
mat mult(mat &A,mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();i++){
		for(int k=0;k<B.size();k++){
			for(int j=0;j<B[0].size();j++){
				(C[i][j] += A[i][k]*B[k][j]%M)%=M;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n){
	if(n==1) return A;
	else if(n%2==0){
		mat B = pow(A,n/2);
		return mult(B,B);
	}else{
		mat B = pow(A,n-1);
		return mult(A,B);
	}
}

ll cnt[20] = {};
ll cnt2[20] = {};
ll p[19] = {1};

int main(){
    cin >> L >> A >> B >> M;
    for(int i=1;i<=18;i++) p[i] = 10*p[i-1];
    /*ll now = A;
    for(int i=0;i<L;i++){
        for(int j=1;j<=18;j++){
            if(now<p[j]){
                cnt2[j]++;
                break;
            }
        }
        now += B;
    }
    for(int i=1;i<=18;i++) cerr << cnt2[i] << " ";
    cerr << endl;
    */for(int i=1;i<=18;i++){
        if(p[i]-1<A) continue;
        if(A+(L-1)*B<p[i-1]) continue;
        cnt[i] = (min(p[i]-1,A+(L-1)*B)-A)/B+1;
        if(i>1 && p[i-1]-1>A) cnt[i] -= max((p[i-1]-1-A)/B+1,0LL);
    }
    ll ans = 0;
    mat res(3,vec(3,0));
    res[0][0] = res[1][1] = res[2][2] = 1;
   /* for(int i=1;i<=18;i++) cerr << cnt[i] << " ";
    cerr << endl;
   */ for(int i=1;i<=18;i++){
        if(cnt[i]==0) continue;
        mat A(3,vec(3,0));
        A[0][0] = p[i]%M; A[0][1] = A[1][1] = A[2][2] = 1;
        A[1][2] = B;
        mat a = pow(A,cnt[i]);
        res = mult(a,res);
    }
    cout << (res[0][2]+A%M*res[0][1]%M)%M << endl;
}