#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int MOD;

struct Matrix {
	vector<vector<long long> > val;
	Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
	void init(int n, int m, long long x = 0) { val.assign(n, vector<long long>(m, x)); }
	size_t size() const { return val.size(); }
	inline vector<long long>& operator [] (int i) { return val[i]; }
	inline Matrix operator * (Matrix other)const
	{
		Matrix R(val.size(), other[0].size());
		for (int i = 0; i != val.size(); ++i)
			for (int j = 0; j != other[0].size(); ++j)
				for (int k = 0; k != other.size(); ++k)
					R[i][j] = (R[i][j] + (val[i][k] * other[k][j]) % MOD) % MOD;
		return R;
	}
	void print()const
	{
		for (int i = 0; i != val.size(); i++)
		{
			for (int j = 0; j != val[i].size(); j++)
			{
				cout << val[i][j];
				if (j + 1 == val[i].size())
				{
					cout << endl;
				}
				else
				{
					cout << " ";
				}
			}
		}
	}
};

Matrix matpow(Matrix A, long long n) {
	Matrix R(A.size(), A.size());
	for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
	while (n > 0) {
		if (n & 1) R = R * A;
		A = A * A;
		n >>= 1;
	}
	return R;
}

long long modpow(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

int f(int n, int r) {
	if (n == 0) return 0;
	if (n % 2 == 1) {
		ll pl = n - 1;
		int x = f(pl, r);
		return ((x * r) % MOD + 1) % MOD;
	}
	else {
		ll pl = n / 2;
		int x = f(pl, r);
		return ((x * modpow(r, pl)) % MOD + x) % MOD;
	}
}
int g(int n, int r) {
	if (n == 0) return 0;
	if (n % 2 == 1) {
		ll pl = n - 1;
		int x = g(pl, r);
		return ((x * r) % MOD + pl) % MOD;
	}
	else {
		ll pl = n / 2;
		int x = g(pl, r);
		return ((x * modpow(r, pl)) % MOD + x + (pl * f(pl, r)) % MOD) % MOD;
	}
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll L, A, B;
	cin >> L >> A >> B >> MOD;

	vector<ll> d(19, 0);
	for (ll i = 1; i <= 18; i++) {
		d[i] = min(((ll)pow(10, i) - A + B - 1) / B, L);
		d[i] = max((ll)0, d[i]);
	}

	for (ll i = 18; i >= 1; i--) {
		d[i] -= d[i - 1];
	}

	Matrix ans(3, 1);
	ans[0][0] = 0, ans[1][0] = A % MOD, ans[2][0] = 1;
	for (ll i = 1; i <= 18; i++) {
		Matrix res(3, 3);
		res[0][0] = (ll)pow(10, i) % MOD, res[0][1] = 1, res[0][2] = 0;
		res[1][0] = 0, res[1][1] = 1, res[1][2] = B % MOD;
		res[2][0] = 0, res[2][1] = 0, res[2][2] = 1;
		res = matpow(res, d[i]);
		ans = res * ans;
	}

	cout << ans[0][0]%MOD << "\n";

	return 0;
}



Measured memory_bytes: 256