//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

ll l,a,b;
ll m;

inline ll addmod(ll a, ll b){
    return (a+b)%m;
}
inline ll mulmod(ll a, ll b){
    return (a*b)%m;
}
inline ll expmod(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b & 1)ret = mulmod(ret, a);
        a = mulmod(a, a);
        b >>= 1;
    }
    return ret;
}

int getdigit(ll x){
    int ret = 0;
    while(x){
        ret++;
        x /= 10;
    }
    return ret;
}

pll solve(ll l, ll r){ // assume A[l] and A[r] have same number of digits
    ll lf = a + l * b;
    ll d = getdigit(lf);
    
    ll stripa = lf % m, stripb = b % m, stairb = b % m;
    ll reta = 0, retb = 0;
    ll sz = r - l + 1;
    ll td = expmod(10, d);
    // solve for strip of A
    while(sz){
        if(sz & 1) reta = addmod(mulmod(reta, td), stripa);
        stripa = addmod(mulmod(stripa, td), stripa);
        td = mulmod(td, td);
        sz >>= 1;
    }
    // solve for stairs of B
    sz = r - l;
    td = expmod(10, d);
    ll copp = 1, copret = 0;
    while(sz){
        if(sz & 1){
            retb = addmod(mulmod(retb, td), addmod(mulmod(stripb, copret), stairb));
            copret = addmod(copret, copp);
        }
        stairb = addmod(mulmod(stairb, td), addmod(mulmod(stripb, copp), stairb));
        stripb = addmod(mulmod(stripb, td), stripb);
        td = mulmod(td, td);
        copp = mulmod(copp, 2);
        sz >>= 1;
    }
    
    d *= r - l + 1;
//    printf("solve %lld-%lld = %lld %lld\n",l,r,reta, retb);
    return {addmod(reta, retb), d};
}

pll dnc(ll l, ll r){ // value under mod, digits
    ll lf = a + l * b;
    ll rg = a + r * b;
    
    if(getdigit(lf) != getdigit(rg)){
        ll mid = (l + r)/2;
        pll vl = dnc(l, mid);
        pll vr = dnc(mid+1, r);
        return {addmod(mulmod(vl.F, expmod(10, vr.S)), vr.F), vl.S + vr.S};
    }else{
//        printf("solve for %lld - %lld\n",lf,rg);
        return solve(l, r);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>l>>a>>b>>m;
    
    cout << dnc(0, l-1).F << endl;
    
    return 0;
}

Measured memory_bytes: 256