#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
int p = 998244353;
/*int p = 1000000007;*/
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
#define bs bitset<5001>

int kai_size = 2600001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size - 1) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 1000001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

int per(int &a, int b) {
	a%=b;
	if (a < 0) { a += b; }
	return a;
}
V<pin> uni(V<pin> &v) {
	sor(v);
	V<pin> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
vel rui(19, 1);
int dig(int n) {
	for (int i = 0; i < 18; i++) {
		if (rui[i] <= n and n < rui[i + 1]) { return i + 1; }
	}
}
int ret1(int diff, int dg) {
	if (diff == 0) { return 0; }
	else if (diff == 1) { return 1; }
	int hl = diff / 2;
	int ans1 = ret1(hl, dg);
	ans1 *= (ru(ru(10, dg), hl) + 1); ans1 %= p;
	if (diff % 2 == 1) {
		ans1 *= ru(10, dg);
		ans1 += 1;
	}
	return ans1 % p;
}
int ret2(int diff, int dg) {
	if (diff <= 0) { return 0; }
	else if (diff == 1) { return 1; }
	int hl = diff / 2;
	int ans2 = ret2(hl, dg);
	ans2 *= (ru(ru(10, dg), hl) + 1); ans2 %= p;
	ans2 += ret1(hl, dg)*(hl%p); ans2 %= p;  
	if (diff % 2 == 1) {
		ans2 += ret1(diff, dg); ans2 %= p;
	}
	return ans2 % p;
}
signed main() {
	long long l, a, b; cin >> l >> a >> b;
	cin >> p;
	rep(i, 18) { rui[i + 1] = rui[i] * 10; }
	int dg = dig(a); int st_dig = dg;
	vel st(19), go(19); int now_st = 0;
	for (; dg <= 19; dg++) {
		st[dg] = now_st;
		go[dg] = (rui[dg] - a + b - 1) / b;
		now_st = go[dg];
		if (go[dg] >= l) { mmin(go[dg], l); break; }
	}
	int ans = 0;
	int now_val = 1;
	for (int i = dg; i >= st_dig; i--) {
		int st_val = a + st[i] * b;
		int diff = go[i] - st[i];
		int ans1 = ret1(diff, i);
		ans1 *= (st_val%p); ans1 %= p;
		int ans2 = ret2(diff - 1, i);
		ans2 *= (b%p); ans2 %= p;
		ans1 += ans2; ans1 %= p;
		ans1 *= now_val; ans1 %= p;
		ans += ans1; ans %= p;
		now_val *= ru(ru(10, diff), i); now_val %= p;
	}
	long long qans = ans;
	cout << qans % p << endl;
	return 0;
}

Measured memory_bytes: 40832