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

typedef vector<long long> vec;
typedef vector<vec> mat;

mat Mul(mat& A, mat& B, long long MOD) {
	mat C(A.size(), vec(B.front().size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B.front().size(); j++) {
				C[i][j] += ((A[i][k] % MOD) * (B[k][j] % MOD) % MOD);
				C[i][j] = C[i][j] % MOD;
			}
		}
	}
	return C;
}

mat Calc(mat A, long long N, long long M) {
	if (N == 1) return A;
	if (N % 2 == 0) {
		mat B = Calc(A, N / 2, M);
		return Mul(B, B, M);
	}
	mat B = Calc(A, N - 1, M);
	return Mul(B, A, M);
}

int main() {
	long long L, A, B, C[18], M, COUNT;
	mat P(1, vec(3));
	cin >> L >> A >> B >> M;
	COUNT = L;
	P[0][0] = 0, P[0][1] = A, P[0][2] = 1;
	for (int i = 0; i < 18; i++) {
		long long N1 = 1, N2 = 1;
		for (int j = 0; j < i; j++) N1 *= 10, N2 *= 10;
		N2 *= 10;
		N1--, N2--;
		if (N2 < A || COUNT == 0) {
			C[i] = 0;
			continue;
		}
		else if (N1 < A) {
			C[i] = (N2 - A) / B + 1;
		}
		else {
			C[i] = (N2 - A) / B - (N1 - A) / B;
		}
		if (COUNT < C[i]) C[i] = COUNT, COUNT = 0;
		else COUNT -= C[i];
	}
	for (int i = 0; i < 18; i++) {
		if (C[i] == 0) continue;
		mat Q(3, vec(3));
		Q[0][0] = (long long)pow(10, i + 1) % M, Q[0][1] = 0, Q[0][2] = 0;
		Q[1][0] = 1, Q[1][1] = 1, Q[1][2] = 0;
		Q[2][0] = 0, Q[2][1] = B % M, Q[2][2] = 1;
		mat R(3, vec(3));
		R = Calc(Q, C[i], M);
		P = Mul(P, R, M);
	}
	cout << P[0][0];
}