#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

Int MOD;
template<typename T>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

};


template<size_t N,typename R>
struct SquareMatrix{
  typedef array<R, N> arr;
  typedef array<arr, N> mat;
  mat dat;

  SquareMatrix(){
    for(size_t i=0;i<N;i++)
      for(size_t j=0;j<N;j++)
        dat[i][j]=R::add_identity();
  }
  SquareMatrix& operator=(const SquareMatrix& a){
    dat=a.dat;
    return (*this);
  }
  bool operator==(const SquareMatrix& a) const{
    return dat==a.dat;
  }

  size_t size() const{return N;};
  arr& operator[](size_t k){return dat[k];};
  const arr& operator[](size_t k) const {return dat[k];};

  static SquareMatrix add_identity(){return SquareMatrix();}
  static SquareMatrix mul_identity(){
    SquareMatrix res;
    for(size_t i=0;i<N;i++) res[i][i]=R::mul_identity();
    return res;
  }

  SquareMatrix operator*(const SquareMatrix &B) const{
    SquareMatrix res;
    for(size_t i=0;i<N;i++)
      for(size_t j=0;j<N;j++)
        for(size_t k=0;k<N;k++)
          res[i][j]=res[i][j]+(dat[i][k]*B[k][j]);
    return res;
  }

  SquareMatrix operator+(const SquareMatrix &B) const{
    SquareMatrix res;
    for(size_t i=0;i<N;i++)
      for(size_t j=0;j<N;j++)
        res[i][j]=dat[i][j]+B[i][j];
    return res;
  }

  SquareMatrix pow(long long n) const{
    SquareMatrix a=*this,res=mul_identity();
    while(n){
      if(n&1) res=res*a;
      a=a*a;
      n>>=1;
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int l,a,b;
  cin>>l>>a>>b>>MOD;

  using T = tuple<Int, Int, Int>;
  vector<T> vt;
  Int c=a+b*(l-1);

  auto calcLen=[](Int x){return (Int)to_string(x).size();};
  Int x=a;
  while(x<=c){
    Int L=(x-a)/b;
    Int R=l;
    if(calcLen(x)==calcLen(c)){
      vt.emplace_back(x,L,R);
      break;
    }
    while(L+1<R){
      Int M=(L+R)>>1;
      if(calcLen(a+b*M)==calcLen(x)) L=M;
      else R=M;
    }
    vt.emplace_back(x,(x-a)/b,R);
    x=a+b*R;
  }
  reverse(vt.begin(),vt.end());
  using M = Mint<Int>;
  using SM = SquareMatrix<2, M>;
  M ans{0};
  M mul{1};
  for(auto st:vt){
    Int x,L,R;
    tie(x,L,R)=st;
    Int len=calcLen(x);

    auto makeB=
      [&](Int num){
        SM A;
        A[0][0]=M(1);A[0][1]=M(1);
        A[1][0]=M(0);A[1][1]=M(10).pow(len);
        return M(b)*(A.pow(num))[0][1];
      };

    using P = pair<M, Int>;
    auto merge=
      [&](P a,P b){
        M x=a.first;
        M y=b.first;
        Int p=a.second;
        Int q=b.second;

        M z{0};
        z+=x*(M(10).pow(len)).pow(q);
        z+=y+M(p)*makeB(q);

        return P(z,p+q);
      };

    Int n=R-L;
    P add(0,0);
    P res(x,1);
    while(n){
      if(n&1) add=merge(add,res);
      res=merge(res,res);
      n>>=1;
    }
    //cout<<add.first.v<<" "<<add.second<<endl;
    ans+=add.first*mul;
    mul*=(M(10).pow(len)).pow(R-L);
  }

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


Measured memory_bytes: 256