#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
//#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y,L,A,B,M,MOD;



class modint {
public:
  long long value;
  //+
	modint operator + (modint mtmp) {
    modint mdnt;
    mdnt.value=(this->value+mtmp.value)%MOD;
    return mdnt;
	}
	modint operator + (long long ltmp) {
    modint mdnt;
    mdnt.value=(this->value+ltmp)%MOD;
    return mdnt;
	}
  //-
	modint operator - (modint mtmp) {
    modint mdnt;
    mdnt.value=(this->value-mtmp.value+MOD)%MOD;
    return mdnt;
	}
	modint operator - (long long ltmp) {
    modint mdnt;
    mdnt.value=(this->value-ltmp+MOD)%MOD;
    return mdnt;
	}
  //*
	modint operator * (modint mtmp) {
    modint mdnt;
    mdnt.value=(this->value*mtmp.value)%MOD;
    return mdnt;
	}
	modint operator * (long long ltmp) {
    modint mdnt;
    long long ltmpm=ltmp%MOD;
    if (ltmpm<0)ltmpm+=MOD;
    mdnt.value=(this->value*ltmp)%MOD;
    return mdnt;
	}
  ///
	modint operator / (long long ltmp) {
    modint mdnt;
    long long ltmpm=ltmp%MOD;
    if (ltmpm<0)ltmpm+=MOD;
    long long mdnv=this->value;

    ll x0=MOD,x1=ltmpm,x2,n0=0LL,n1=1LL,n2,t=mdnv%ltmpm,m,ans;
    if (t==0){
      mdnt.value=mdnv/ltmpm;
      return mdnt;
    } 
      for(int i=0;i<900;i++){
        m=x0/x1;
        x2=x0-x1*m;
        n2=(n0-m*n1)%MOD;
        if (x2==1){
          ans=(n2+MOD)%MOD;
          break;
        }
        x0=x1;x1=x2;
        n0=n1;n1=n2;
      }

    mdnt.value=(mdnv+((t*ans)%MOD)*ltmpm-t)/ltmpm;
    return mdnt;
  }
  
	modint operator / (modint mtmp) {
    modint mdnt;
    mdnt.value=this->value;
    return mdnt/mtmp.value;
	}

  //代入演算子のオーバーロード
  modint &operator = (const modint mtmp) 
  {
      this->value = mtmp.value%MOD;
      return *this;
  }
  modint &operator = (const long long ltmp) 
  {
      this->value = ltmp%MOD;
      return *this;
  }
  
  //exp関数
  //aのn乗 mod c
  modint exp(long long n){
    long long ans=1LL,aa=this->value,beki=n;
    for(int i=0;i<64;i++){
      if (beki%2==1) ans=ans*aa%MOD;
      aa=aa*aa%MOD;
      beki/=2;
      if (beki==0)break;
    }
    modint mdnt;
    mdnt.value=ans;
    return mdnt;
  }
  //friend ostream& operator << (ostream& os, const modint& m);
};


ostream& operator << (ostream& os, const modint& m)
{
  os << m.value;
  return os;
}








//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}










ll mylog10(unsigned long long a){
	unsigned long long w=1ULL;
	for(;w<=a;w*=10ULL){
	}
	return (ll)(w/10ULL);
}


void matmul(vvi &C,vvi A,vvi B)
{
	REP(i,k){	
		REP(j,k){	
			C[i][j]=0;
			REP(l,k){
				C[i][j]+=A[l][j]*B[i][l];
				C[i][j]%=M;
			}
		}
	}
}

void matpow(vvi &matans,vvi &imat,ll num){
  //vvi matans(k, vi(k,0));  // k * k の正方行列
  vvi updmat(k, vi(k,0));  // k * k の正方行列
  REP(i,k) matans[i][i]=1;//単位行列 I
  REP(i,k)REP(j,k)updmat[i][j]=imat[i][j];
	while(num)
	{
		if (num%2==1)
		{
			matmul(matans,matans,updmat);
		}
		num/=2;
		matmul(updmat,updmat,updmat);
	}
	return;
}



int main(){
  cin >> L >> A >> B>>M;
  MOD=M;
  modint ans;
  ans=0;
  ll lasts=(L-1)*B+A;


  k=3;
  vvi mat2d(k, vi(k));  // k * k の正方行列

  mat2d[0][0]=1;
  mat2d[1][0]=100;
  mat2d[2][0]=0;
  mat2d[1][1]=1;
  mat2d[2][1]=-(B%M)+M;
  mat2d[0][0]=1;
  mat2d[2][2]=1;

  modint e,sm;
  sm=1;
  //e=10;

	for (int i=0;i<999;i++){
		ll lowL=(mylog10(lasts)-1-A)/B;
		//if (lowL<0)lowL=0;
		if ((mylog10(lasts)-1-A)<0)
		{
			lowL=-1;
		}
		ll Lnmu=L-1-lowL;
		
		//cout<<(mylog10(lasts)-1)<<endl;
		//cout<<Lnmu<<endl;
		//cout<<lasts<<endl;

		mat2d[1][0]=(mylog10(lasts)%M*10LL)%M;
		mat2d[2][2]=(mylog10(lasts)%M*10LL)%M;
		mat2d[1][1]=(mylog10(lasts)%M*10LL)%M;
		mat2d[2][1]=(-(B%M)+M)*((mylog10(lasts)%M*10LL)%M)%M;

  		vvi ansmat(k, vi(k,0));  // k * k の正方行列
		matpow(ansmat,mat2d,Lnmu-1);
		modint pans;
		//cout<<ansmat[0][0]<<" "<<ansmat[1][0]<<" "<<ansmat[2][0]<<" "<<endl;
		pans=(ansmat[0][0]*(lasts%M)+ansmat[1][0]*((lasts%M-B%M+M)%M)+ansmat[2][0]);
		ans=ans+pans*sm;

		e=(mylog10(lasts)%M*10LL);
		sm=sm*e.exp(Lnmu);

		L=lowL+1;
		lasts=(L-1)*B+A;
		if (L==0)break;
	}




  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256