#include <bits/stdc++.h>

////////////
// 行列型 //
///////////

// 加算、減算、乗算をもつM×N型行列
// M=Nで環をつくる
template<typename T = int64_t>
class Matrix {
private:
	using RowVector = std::vector<T>;

	std::vector<RowVector> container_;

	// 必要に応じて書換
	const T ring_one{1ll};
	const T ring_zero{};

public:
	const int M, N;

	Matrix(const int row_size, const int column_size)
		: M(row_size), N(column_size), container_(row_size, RowVector(column_size)){}
	// ムーブコンストラクタ
	Matrix(Matrix&& mat)
		: M(mat.M), N(mat.N), container_(std::move(mat.container_)){}
	// コピーコンストラクタ
	Matrix(const Matrix& mat)
		: M(mat.M), N(mat.N), container_(mat.container_){}

	// 要素アクセス
	RowVector& operator[](const int r) { return container_[r]; }
	const RowVector& operator[](const int r) const { return container_[r]; }
	// イテレータ
	typename decltype(container_)::iterator begin(){ return container_.begin(); }
	typename decltype(container_)::iterator end(){ return container_.end(); }

	// 環の演算
	Matrix operator+(const Matrix& mat) const
	{
		Matrix ret{*this};
		for (int r_i{}; r_i < M; r_i++)
			for (int c_i{}; c_i < N; c_i++)
				ret[r_i][c_i] += mat[r_i][c_i];
		return std::move(ret);
	}
	Matrix operator-(const Matrix& mat) const
	{
		Matrix ret{*this};
		for (int r_i{}; r_i < M; r_i++)
			for (int c_i{}; c_i < N; c_i++)
				ret[r_i][c_i] -= mat[r_i][c_i];
		return std::move(ret);
	}
	Matrix operator*(const Matrix& mat) const
	{
		Matrix ret(this->M, mat.N);
		for (int r_i{}; r_i < this->M; r_i++)
			for (int c_i{}; c_i < mat.N; c_i++)
				for (int l_i{}; l_i < this->N; l_i++)
					ret[r_i][c_i] += (*this)[r_i][l_i] * mat[l_i][c_i];
		return std::move(ret);
	}
	std::vector<T> operator*(const std::vector<T>& vec) const
	{
		std::vector<T> ret(M);
		for (int r_i{}; r_i < M; r_i++)
			for (int c_i{}; c_i < N; c_i++)
				ret[r_i] += (*this)[r_i][c_i] * vec[c_i];
		return std::move(ret);
	}

	// 累乗
	Matrix operator^(const int64_t index) const
	{
		Matrix ret((*this).getOne()), pow(*this);
		for (int64_t i{index}; i > 0; i >>= 1)
		{
			if (i & 1)
				ret *= pow;
			pow *= pow;
		}
		return std::move(ret);
	}

	// 代入演算子
	Matrix& operator=(const Matrix& mat)
	{
		this->container_ = mat.container_;
		return *this;
	}	
	Matrix& operator+=(const Matrix& mat)
	{
		*this = *this + mat;
		return *this;
	}
	Matrix& operator-=(const Matrix& mat)
	{
		*this = *this - mat;
		return *this;
	}
	Matrix& operator*=(const Matrix& mat)
	{
		*this = *this * mat;
		return *this;
	}

	// ゼロ行列と単位行列
	constexpr Matrix getOne() const
	{
		Matrix ret(M, N);
		for (int i{}; i < N; i++)
			ret[i][i] = ring_one;
		return std::move(ret);
	}
	constexpr Matrix getZero() const
	{
		return Matrix(M, N);
	}
};

/////////////////////
// 動的modのModInt //
////////////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = DynamicModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
int64_t mod{};
class DynamicModInt {
private:
	int64_t integer_;

public:
	DynamicModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	DynamicModInt operator+(const DynamicModInt& operand) const
	{
		DynamicModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod)
			ret.integer_ -= mod;
		return ret;
	}
	DynamicModInt operator-(const DynamicModInt& operand) const
	{
		DynamicModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod;
		return ret;
	}
	DynamicModInt operator*(const DynamicModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod};
	}

	// 累乗
	DynamicModInt operator^(const int64_t operand) const
	{
		DynamicModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	DynamicModInt& operator=(const DynamicModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	DynamicModInt& operator+=(const DynamicModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	DynamicModInt& operator-=(const DynamicModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	DynamicModInt& operator*=(const DynamicModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}

	// その他
	operator int64_t() { return integer_; }

	DynamicModInt getOne() const
	{
		return DynamicModInt(1ll);
	}
	DynamicModInt getZero() const
	{
		return DynamicModInt(0ll);
	}
};
using DMint = DynamicModInt;

// https://atcoder.jp/contests/abc129/tasks/abc129_f
int main()
{
	int64_t L, A, B;
	scanf("%lld%lld%lld%lld", &L, &A, &B, &mod);
	std::vector<int64_t> digit(19, -1);
	int64_t ten_pow{1};
	for (int i{1}; ; i++)
	{
		ten_pow *= 10;
		if (A >= ten_pow) continue;
		digit[i] = (ten_pow - 1 - A) / B;
		if (digit[i] >= L - 1)
		{
			digit[i] = L - 1;
			break;
		}
	}

	std::vector<DMint> sum(19);
	DMint a_mod(A % mod), b_mod(B % mod), ten_pow_mod(1ll);
	for (int i{1}; digit[i - 1] != L - 1; i++)
	{
		ten_pow_mod *= DMint(10);
		if (digit[i] < 0 || digit[i] == digit[i - 1]) continue;
		int64_t num{digit[i] - digit[i - 1]};

		Matrix<DMint> aMat(2, DMint(2));
		aMat[0][0] = ten_pow_mod;
		aMat[0][1] = aMat[1][1] = DMint(1);
		std::vector<DMint> beginA{DMint(0), DMint(1)};
		sum[i] = ((aMat ^ num) * beginA)[0] * (a_mod + (DMint((digit[i - 1] + mod) % mod) + DMint(1ll)) * b_mod);
		
		Matrix<DMint> bMat(4, DMint(4));
		bMat[0][0] = ten_pow_mod;
		bMat[0][1] = bMat[1][1] = bMat[2][0] = bMat[3][1] = bMat[2][2] = bMat[3][3] = DMint(1ll);

		Matrix<DMint> beginB(4, DMint(2));
		beginB[0][0] = beginB[1][1] = DMint(1);
		sum[i] += b_mod * ((bMat ^ num) * beginB * beginA)[2];
	}
	std::vector<DMint> shift(19, DMint(1ll));
	for (int i{17}; i > 0; i--)
	{
		if (digit[i + 1] < 0) continue;
		DMint tmp(1);
		ten_pow_mod = DMint(10);
		for (int64_t j{(digit[i + 1] - digit[i])}; j > 0; j >>= 1, ten_pow_mod *= ten_pow_mod)
			if (j & 1)
				tmp *= ten_pow_mod;
		shift[i] = shift[i + 1];
		for (int64_t j{i + 1}; j > 0; j >>= 1, tmp = tmp * tmp % mod)
			if (j & 1)
				shift[i] *= tmp;
		sum[i] *= shift[i];
	}
	DMint ans{};
	for (int i{1}; i <= 18; i++)
	{
		if (digit[i] < 0 || digit[i] == digit[i - 1]) continue;
		ans += sum[i];
	}
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256