#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 10000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < vi, int > a, pair < vi, int > b)//true for a before b
{
	if(a.F.empty())
		return 1;
	if(b.F.empty())
		return 0;
	int i;
	fo(i,0,min(sz(a.F),sz(b.F)))
	{
		if(a.F[i] < b.F[i])
			return 1;
		else if(a.F[i] > b.F[i])
			return 0;
	}
	return (sz(a.F) <= sz(b.F));
}

const int N = (10) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;
const int SQRT = BUCK+9;

ll modx(ll Base, ll exponent, ll m)
{
	Base %= m;
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1LL)
			ans = (ans * Base)%m;
		Base = (Base * Base)%m;
		exponent = exponent >> 1;
	}
	return ans;
}

ll last_ind[N];

inline int count_digs(ll n)
{
	int ans = 0;
	while(n > 0)
	{
		ans++;
		n /= 10LL;
	}
	return ans;
}

ll binsea(ll l, ll r, ll a, ll b, int val)
{
	if(l > r)
		return 0LL;
	ll mid = (l+r)>>1LL;
	if(count_digs(a+mid*b) <= val)
		return max(mid, binsea(mid+1LL,r,a,b,val));
	return binsea(l,mid-1LL,a,b,val);
}

// This a property of abhishek_1997

ll A[N], A_temp[N];// 1 x N
ll B[N][N], B_temp[N][N];// N x N

void matrix_square(int n, ll MOD)// B_temp = B x B
{
	int i, j, k;
	fo(i,1,n+1)
		fo(j,1,n+1)
			B_temp[i][j] = 0LL;
	fo(i,1,n+1)
		fo(j,1,n+1)
			fo(k,1,n+1)
				B_temp[i][j] = (B_temp[i][j] + B[i][k]*B[k][j])%MOD;
	fo(i,1,n+1)
		fo(j,1,n+1)
			B[i][j] = B_temp[i][j];
	return;
}

void matrix_multi(int n, ll MOD)// A_temp = A x B
{
	int i, j;
	fo(i,1,n+1)
		A_temp[i] = 0LL;
	fo(i,1,n+1)
		fo(j,1,n+1)
			A_temp[i] = (A_temp[i] + A[j]*B[j][i])%MOD;
	fo(i,1,n+1)
		A[i] = A_temp[i];
	return;
}

void matrix_expo(ll val, int n, ll MOD)
{
	while(val > 0LL)
	{
		if(val&1LL)// Update A
			matrix_multi(n,MOD);
		matrix_square(n,MOD);// Update B
		val >>= 1;
	}
	return;
}

ll solve(ll val, int m, ll MOD)
{
	matrix_expo(val, m, MOD);
	return A[1];
}

ll brute(ll l, ll r, ll a, ll b, ll m, ll val)
{
	ll ans = 0, i;
	fo(i,l,r+1LL)
		ans = (ans*val + (a+i*b))%m;
	return ans;
}

ll func(ll l, ll r, ll a, ll b, ll m, ll val)
{
	int i, j;
	A[1] = A[2] = (a + b*l)%m;
	A[3] = b%m;
	fo(i,1,4)
		fo(j,1,4)
			B[i][j] = 0;
	B[1][1] = val;
	B[2][1] = B[3][1] = B[2][2] = B[3][2] = B[3][3] = 1;
	ll ans = solve(r-l,3,m);
	// ll br = brute(l,r,a,b,m,val);
	// cout << "  brute : " << br << '\n';
	// cout << "  expon : " << ans << '\n';
	return ans;
}

void solve()
{
	int i, max_digs, min_digs;
	ll L, a, b, m, ans = 0, l, r, val = 1, temp, shit;
	cin >> L >> a >> b >> m;
	fo(i,0,N)
		last_ind[i] = -1;
	max_digs = count_digs(a+(L-1LL)*b);
	min_digs = count_digs(a);
	fo(i,min_digs,max_digs+1)
		last_ind[i] = binsea(1LL,L-1LL,a,b,i);
	for(i = max_digs; i >= min_digs; i--)
	{
		r = last_ind[i];
		l = last_ind[i-1]+1LL;
		temp = modx(10LL,i,m);
		if(l <= r)
		{
			// cout << i << " : " << l << " " << r << " : " << val << " " << temp << '\n';
			shit = func(l,r,a,b,m,temp);
			ans = (ans + shit*val)%m;
			temp = modx(temp,r-l+1LL,m);
			val = (val * temp)%m;
		}
	}
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(15);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256