#include <iostream>
#include <vector>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int powmod(int a, int n, int mod) {
	if (a >= mod) a %= mod;
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int p10[19];
int L, a, b, m;

//r^0 + … + r^(n - 1)
int tohi(int r, int n) {
	int s[61];
	int i;
	
	s[0] = 1;
	for (i = 0; i < 60; i++) {
		s[i + 1] = s[i] + powmod(r, (1LL << i), m) * s[i];
		s[i + 1] %= m;
	}
	
	int cnt = 0;
	int ret = 0;
	for (i = 59; i >= 0; i--) {
		if ((n >> i) % 2 == 1) {
			ret += powmod(r, cnt, m) * s[i];
			ret %= m;
			cnt += (1LL << i);
		}
	}
	
	//cout << "tohi(" << r << ", " << n << ") = " << ret << endl;
	return ret;
}

//0 * r^0 + … + (n - 1) * r^(n - 1)
int tohi2(int r, int n) {
	int s[61];
	int t[61];
	int i;
	
	s[0] = 1;
	for (i = 0; i < 60; i++) {
		s[i + 1] = s[i] + powmod(r, (1LL << i), m) * s[i];
		s[i + 1] %= m;
	}
	
	t[0] = 0;
	for (i = 0; i < 60; i++) {
		t[i + 1] = t[i] + powmod(r, (1LL << i), m) * ((1LL << i) % m * s[i] % m + t[i]) % m;
		t[i + 1] %= m;
	}
	
	int cnt = 0;
	int ret = 0;
	for (i = 59; i >= 0; i--) {
		if ((n >> i) % 2 == 1) {
			int res1 = powmod(r, cnt, m);
			int res2 = cnt % m * s[i] + t[i]; res2 %= m;
			ret += res1 * res2;
			ret %= m;
			cnt += (1LL << i);
		}
	}
	
	//cout << "tohi2(" << r << ", " << n << ") = " << ret << endl;
	return ret;
}

//a, a + d, …, a + (n - 1)d, x桁
int calc(int a, int d, int n, int x) {
	int syu = (a % m + (n - 1) % m * d % m) % m;
	int res1 = syu * tohi(p10[x], n) % m;
	int res2 = d % m * tohi2(p10[x], n) % m;
	return (res1 + m - res2) % m;
}

signed main() {
	int i, j;
	
	p10[0] = 1;
	for (i = 1; i < 19; i++) p10[i] = p10[i - 1] * 10;
	
	cin >> L >> a >> b >> m;
	
	int ans = 0;
	vector<int> cnts;
	for (i = 17; i >= 0; i--) {
		if (a >= p10[i + 1]) continue;
		
		int l, r;	//[l, r]項目はi+1桁
		if (a >= p10[i]) { l = 0; }
		else { l = (p10[i] - a + b - 1) / b; }
		r = (p10[i + 1] - a + b - 1) / b - 1;
		if (r >= L) r = L - 1;
		if (l > r) continue;
		//cout << i << ", " << "[l, r] = " << l << ", " << r << endl;
		
		int syo = a + l * b;
		int n = r - l + 1;
		int res1 = 1;
		
		rep(j, cnts.size()) {
			res1 *= powmod(10, cnts[j], m);
			res1 %= m;
		}
			
		ans += res1 * calc(syo, b, n, i + 1) % m;
		ans %= m;
		
		//cnt += n * (i + 1); <- オーバーフローするのでちょっとズルします。
		rep(j, i + 1) cnts.push_back(n);
	}
	cout << ans << endl;
	return 0;
}