#include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
        if(x < 0) x += MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

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

void Main(){
    ll L,A,B; cin >> L >> A >> B >> MOD;
    ll d[20][2]; REP(i,20)REP(j,2) d[i][j] = 1;
    REP(i,19){
        ll l = 0, r = L+1;
        while(r-l>1){
            ll x = (l+r)/2;
            if(digit(A+(x-1)*B) < i+1) l = x;
            else r = x;
        }
        d[i][1] = d[i+1][0] = r;
    }
    d[19][1] = L+1;

    ll mind = digit(A), maxd = digit(A+(L-1)*B);

    mint t(10);
    vector<mint> sum(20);
    FOR(i,mind,maxd+1){
        ll len = d[i][1] - d[i][0];
        if(len <= 0) continue;

        ll cnt = 0;
        mint doub(A+(d[i][0]-1)*B), b(B);
        vector<mint> a(60); a[0] = t.pow(i); REP(j,59) a[j+1] = a[j]*a[j];
        while(len){
            if(len&1){
                sum[i] = sum[i]*a[cnt] + doub;
                doub += b*(1LL<<cnt);
            }
            doub = doub*a[cnt] + doub + b*(1LL<<cnt);
            b = b*a[cnt] + b;
            len >>= 1;
            cnt++;
        }
    }

    mint ans;
    t = mint(1);
    RFOR(i,maxd+1,mind){
        ll len = d[i][1] - d[i][0];
        if(len <= 0) continue;
        ans += sum[i]*t;
        t *= mint(10).pow(i).pow(len);
    }

    cout << ans.x << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3660