#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
::std::uint_fast64_t MOD;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------
//--Matrix
//-------------------------------------------------
template<typename T>
class Matrix
{
private:
    using V = ::std::vector<T>;
    using M = ::std::vector<V>;
    M dat;
    int h,w;
public:
    Matrix(int h_, int w_):h(h_),w(w_){
        dat.resize(h,V(w));
    }
    Matrix(const M &mat){
        h = mat.size();
        w = mat[0].size();
        dat.resize(h,V(w));
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]=mat[i][j];
    }
    Matrix(const Matrix &m){
        h = m.h; w = m.w;
        dat.resize(h,V(w));
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]=m.dat[i][j];
    }
    static Matrix getI(int n){
        Matrix ret(n,n);
        for(int i=0;i<n;i++) ret[i][i] = 1;
        return ret;
    }
    Matrix& operator+=(const Matrix &m){
        assert(m.h==h && m.w==w);
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]+=m.dat[i][j];
        return *this;
    }
    Matrix& operator-=(const Matrix &m){
        assert(m.h==h && m.w==w);
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]-=m.dat[i][j];
        return *this;
    }
    Matrix& operator*=(const Matrix &m){
        assert(m.h==w);
        M ret(h, V(m.w));
        for(int i=0; i<h; i++)
            for(int j=0; j<m.w; j++)
                for(int k=0; k<w; k++)
                    ret[i][j]+=dat[i][k]*m.dat[k][j];
        dat.swap(ret);
        return *this;
    }
    Matrix& operator*=(T c){
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                dat[i][j]*=c;
        return *this;
    }
    Matrix& operator^=(::std::uint_fast64_t t){
        assert(h==w);
        Matrix ret = Matrix::getI(h);
        Matrix m(*this);
        while(t){
            if (t&1) ret*=m;
            m*=m;
            t>>=1;
        }
        dat.swap(ret.dat);
        return *this;
    }
    Matrix operator+(const Matrix &m) const {return Matrix(*this)+=m;}
    Matrix operator-(const Matrix &m) const {return Matrix(*this)-=m;}
    Matrix operator*(const Matrix &m) const {return Matrix(*this)*=m;}
    Matrix operator*(T c) const {return Matrix(*this)*=c;}
    Matrix operator^(::std::uint_fast64_t t) const {return Matrix(*this)^=t;}
    Matrix operator-() const {return Matrix(*this)*=-1;}
    V& operator[](int h){return dat[h];}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l,a,b; cin>>l>>a>>b>>MOD;
    ll p10[19];
    p10[0] = 1;
    rep(i,18) p10[i+1]=p10[i]*10;
    Matrix<mint> cvt = Matrix<mint>::getI(3);
    Matrix<mint> mat(3,3);
    mat[0][0] = 1;
    mat[1][0] = 1;
    mat[2][2] = 1;
    RFOR(d,18,1){
        ll mi = p10[d-1];
        ll ma = p10[d]-1;
        if (a>ma) continue;
        if (a+b*(l-1)<mi) continue;
        ll left = (mi-a+b-1)/b;
        chmax(left, 0ll);
        ll right = (ma-a)/b;
        chmin(right, l-1);
        mint B = b;
        ll T = right-left+1;
        mint c = p10[d];
        mat[0][2] = B;
        mat[1][1] = c;
        cvt *= mat^T;
    }
    Matrix<mint> vec(3,1);
    vec[0][0] = a;
    vec[2][0] = 1;
    cvt*=vec;
    cout<<cvt[1][0]<<endl;
    return 0;
}


Measured memory_bytes: 384