#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll qpow(ll a,ll b,ll M) {a%=M;ll s=1;while(b){if(b&1)s=(s*a)%M;a=(a*a)%M;b>>=1;}return s; }
ll qmul(ll a,ll b,ll M) {a%=M;ll s=0;while(b){if(b&1)s=(s+a)%M;a=(a+a)%M;b>>=1;}return s; }
ll M,pt[20];
struct Matrix
{
ll mat[3][3];
Matrix() {memset(mat,0,sizeof(mat));}
Matrix operator * (Matrix b)
{
Matrix res;
rep(i,0,2) rep(j,0,2) rep(k,0,2) res.mat[i][j] = (res.mat[i][j] + mat[i][k]*b.mat[k][j]%M)%M;
return res;
}
Matrix operator ^ (ll b)
{
Matrix res,A=*this;
rep(i,0,2) res.mat[i][i] = 1;
while(b){
if(b&1) res = res * A;
A = A*A;
b>>=1;
}
return res;
}
};
int main()
{
fastio(); ll n,a,b;
cin>>n>>a>>b>>M;
ll ans = 0;
pt[0] = 1;
rep(i,1,18) pt[i] = pt[i-1]*10;
ll L = a,R = a+(n-1)*b;
rep(i,1,18){
if(L < pt[i]){
ll e = (pt[i]-L-1)/b*b+L;
if(e>R) e = R;
ll t = (e-L)/b + 1;
Matrix A;
A.mat[0][0] = pt[i]%M;
A.mat[0][1] = A.mat[1][1] = A.mat[2][2] = 1;
A.mat[1][2] = b%M;
A = A^t;
ans = (ans*A.mat[0][0]%M + L%M*A.mat[0][1]%M + A.mat[0][2]) %M;
if(e==R)break;
L = e + b;
}
}
cout<<ans<<endl;
return 0;
}