#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



ll L,A,B,M;
ll S;

struct MOD_INT{
  ll x;

  MOD_INT(ll arg_x){
	  x = arg_x;
	  x %= M;
  }

  MOD_INT& operator+=(const MOD_INT a) {
    (x += a.x) %= M;
    return *this;
  }
  MOD_INT& operator-=(const MOD_INT a) {
    (x += M-a.x) %= M;
    return *this;
  }
  MOD_INT& operator*=(const MOD_INT a) {
    (x *= a.x) %= M;
    return *this;
  }
  MOD_INT operator+(const MOD_INT a) const {
	  MOD_INT res(*this);
    return res+=a;
  }
  MOD_INT operator-(const MOD_INT a) const {
	  MOD_INT res(*this);
    return res-=a;
  }
  MOD_INT operator*(const MOD_INT a) const {
    MOD_INT res(*this);
    return res*=a;
  }
};


MOD_INT mod_pow(MOD_INT x,ll count, ll mod){

	if(count == 0){

		return 1;
	}

	if(count%2 == 1){

		return mod_pow(x,count-1,mod)*x;
	}
	else{

		MOD_INT y = mod_pow(x,count/2,mod);
		return y*y;
	}
}


MOD_INT f(ll loc){
	if(loc == 0){

		return 0;
	}

	MOD_INT ret(0);

	if(loc%2 == 1){

		ll tmp = loc-1;
		ret = f(tmp);
		return ret*S+1;

	}else{

		ll tmp = loc/2;
		ret = f(tmp);
		return ret*mod_pow(S,loc/2,M)+ret;
	}
}


MOD_INT g(ll loc){
	if(loc == 0){

		return 0;
	}

	MOD_INT ret(0);

	if(loc%2 == 1){

		ll tmp = loc-1;
		ret = g(tmp);
		return ret*S+MOD_INT(B)*tmp;

	}else{

		ll tmp = loc/2;
		ret = g(tmp);
		return ret = ret*mod_pow(S,tmp,M)+ret+MOD_INT(B)*tmp*f(tmp);
	}
}


int main(){

	scanf("%lld %lld %lld %lld",&L,&A,&B,&M);

	MOD_INT ans = 0;

	S = 10;
	ll last = A+B*(L-1);
	ll head,tail,num;

	for(ll i = 1; i <= 18; i++,S *= 10){

		ll mini = S/10,maxi = S-1;
		if(A > maxi || last < mini)continue;

		if(A >= mini){

			head = A;

		}else{

			head = ((mini-A)+(B-1))/B*B+A;
			head = min(head,last);
		}

		if(last <= maxi){

			tail = last;
		}else{
			tail = (maxi-A)/B*B+A;
		}

		num = (tail-head)/B+1;
		//printf("i:%lld head:%lld  tail:%lld num:%lld\n",i,head,tail,num);

		ans *= mod_pow(S,num,M);
		ans += f(num)*head;
		ans += g(num);
	}

	printf("%lld\n",ans.x);

	return 0;
}
