#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

struct Mint {
    static unsigned uMod;
    unsigned x;

    Mint() : x(0) {}
    Mint(const Mint &y) : x(y.x) {}
    Mint(unsigned y) { if (uMod <= y) y %= uMod; x = y; }
    Mint(int y) { if (y < 0 || (long long)uMod <= y) y %= uMod; if (y < 0) y += uMod; x = y; }
    Mint(unsigned long long y) { if (uMod <= y) y %= uMod; x = y; }
    Mint(long long y) { if (y < 0 || uMod <= y) y %= uMod; if (y < 0) y += uMod; x = y; }

    Mint& operator+=(const Mint &y) { if ((x += y.x) >= uMod) x -= uMod; return *this; }
    Mint& operator-=(const Mint &y) { if ((x += uMod - y.x) >= uMod) x -= uMod; return *this; }
    Mint& operator*=(const Mint &y) { x = (unsigned long long)x * y.x % uMod; return *this; }
    Mint& operator/=(const Mint &y) { x = (unsigned long long)x * y.inv().x % uMod; return *this; }
    Mint operator-() const { return x? uMod - x: 0; }

    int geti() const { return x; }

    Mint inv() const {
	unsigned a = uMod, b = x; int u = 0, v = 1;
	while (b) {
	    int t = a / b;
	    a -= t * b; swap(a, b);
	    u -= t * v; swap(u, v);
	}
	if (u < 0) u += uMod;
	return Mint(u);
    }

    Mint pow(long long y) const {
	Mint b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend Mint operator+(Mint x, const Mint &y) { return x += y; }
    friend Mint operator-(Mint x, const Mint &y) { return x -= y; }
    friend Mint operator*(Mint x, const Mint &y) { return x *= y; }
    friend Mint operator/(Mint x, const Mint &y) { return x /= y; }
    friend bool operator<(const Mint x, const Mint y) { return x.x < y.x; }
    friend bool operator==(const Mint x, const Mint y) { return x.x == y.x; }
    friend bool operator!=(const Mint x, const Mint y) { return x.x != y.x; }
};
unsigned Mint::uMod;
Mint solveA(Mint ten, LL n) {
    if (n == 0) return 0;
    if (n & 1) return solveA(ten, n-1) * ten + 1;
    else return (1+ten.pow(n/2)) * solveA(ten, n/2);
}
Mint solveB(Mint ten, LL n) {
    if (n == 0) return 0;
    if (n & 1) return solveB(ten, n-1) * ten + n - 1;
    else {
	Mint a = solveA(ten, n/2);
	Mint b = solveB(ten, n/2);
	return b * (ten.pow(n/2) + 1) + n/2*a;
    }
}

LL L, A, B;


void MAIN() {
    LL M;
    scanf("%lld%lld%lld%lld", &L, &A, &B, &M);
    Mint::uMod = M;

    Mint ans = 0;
    LL ten = 10;
    LL pos = 0;
    while (pos < L) {
	LL lo = pos-1, hi = L;
	while (hi - lo > 1) {
	    LL mid = (lo+hi)/2;
	    if (A + mid*B >= ten) hi = mid;
	    else lo = mid;
	}

	if (pos < hi) {
	    Mint aa = solveA(ten, hi-pos);
	    Mint bb = solveB(ten, hi-pos);

	    ans = ans * Mint(ten).pow(hi-pos) + (A+B*pos) * aa + B * bb;

	    pos = hi;
	}
	ten *= 10;
    }
    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256