#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
	#include <boost/multiprecision/cpp_int.hpp>
	#include <boost/multiprecision/cpp_dec_float.hpp>
	using bll = boost::multiprecision::cpp_int;
	using bdouble = boost::multiprecision::cpp_dec_float_100;
#endif
#ifdef LOCAL_DEV
	void debug_impl() { std::cerr << std::endl; }
	template<typename Head, typename... Tail> void debug_impl(Head head, Tail... tail) { std::cerr << " " << head << (sizeof...(tail) ? "," : ""); debug_impl(tail...); }
	#define debug(...) std::cerr << std::boolalpha << "(" << #__VA_ARGS__ << ") ="; debug_impl(__VA_ARGS__); std::cerr << std::noboolalpha;
#else
	#define debug(...)
#endif
#ifdef LOCAL_TEST
	#define BOOST_STACKTRACE_USE_ADDR2LINE
	#define BOOST_STACKTRACE_ADDR2LINE_LOCATION /usr/local/opt/binutils/bin/addr2line
	#define _GNU_SOURCE
	#include <boost/stacktrace.hpp>
	template<typename T> class dvector : public std::vector<T> {
	public:
		dvector() : std::vector<T>() {}
		explicit dvector(size_t n, const T& value = T()) : std::vector<T>(n, value) {}
		dvector(const std::vector<T>& v) : std::vector<T>(v) {}
		dvector(const std::initializer_list<T> il) : std::vector<T>(il) {}
		dvector(const typename std::vector<T>::iterator first, const typename std::vector<T>::iterator last) : std::vector<T>(first, last) {}
		dvector(const std::string::iterator first, const std::string::iterator last) : std::vector<T>(first, last) {}
		T& operator[](size_t n) {
			try { return this->at(n); } catch (const std::exception& e) {
				std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
			}
		}
		const T& operator[](size_t n) const {
			try { return this->at(n); } catch (const std::exception& e) {
				std::cerr << boost::stacktrace::stacktrace() << std::endl; return this->at(n);
			}
		}
	};
	class dbool {
	private:
		bool boolvalue;
	public:
		dbool() : boolvalue(false) {}
		dbool(bool b) : boolvalue(b) {}
		dbool(const dbool &b) : boolvalue(b.boolvalue) {}
		operator bool&() { return boolvalue; }
		operator const bool&() const { return boolvalue; }
	};
	template<typename T> std::ostream& operator<<(std::ostream& s, const dvector<T>& v) {
		for (int i = 0, len = v.size(); i < len; ++i){ s << v[i]; if (i < len - 1) s << "\t"; } return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const dvector< dvector<T> >& vv) {
		for (int i = 0, len = vv.size(); i < len; ++i){ s << vv[i] << std::endl; } return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const std::set<T>& se) {
		s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}" << std::endl; return s; }
	template<typename T> std::ostream& operator<<(std::ostream& s, const std::multiset<T>& se) {
		s << "{ "; for (auto itr = se.begin(); itr != se.end(); ++itr){ s << (*itr) << "\t"; } s << "}" << std::endl; return s; }
	template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::map<T1, T2>& m) {
		s << "{" << std::endl; for (auto itr = m.begin(); itr != m.end(); ++itr){ s << "\t" << (*itr).first << " : " << (*itr).second << std::endl; } s << "}" << std::endl; return s; }
	template<typename T1, typename T2> std::ostream& operator<<(std::ostream& s, const std::pair<T1, T2>& p) { 
		return s << "(" << p.first << ", " << p.second << ")"; }
	#define vector dvector
	#define bool dbool
	class SIGFPE_exception : std::exception {};
	class SIGSEGV_exception : std::exception {};
	void catch_SIGFPE(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGFPE_exception();	}
	void catch_SIGSEGV(int e) { std::cerr << boost::stacktrace::stacktrace() << std::endl; throw SIGSEGV_exception(); }
	signed convertedmain();
	signed main(){ signal(SIGFPE, catch_SIGFPE); signal(SIGSEGV, catch_SIGSEGV); convertedmain(); return 0;	}
	#define main() convertedmain()
#endif
//#define int long long
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
//constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> &v) { for(ll i=0, N=v.size(); i<N; i++) std::cout << v[i] << " \n"[i==N-1]; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

/*-----8<-----template-----8<-----*/
ll MOD=INF;
inline  ll extgcd(ll a, ll b, ll &x, ll &y){ ll g = a; x = 1; y = 0; if(b){ g = extgcd(b, a % b, y, x); y -= a / b * x; } return g; }
inline  ll invmod(ll a, ll m = MOD){ ll x = 0, y = 0; extgcd(a, m, x, y); return (x + m) % m; }
class Modint{
public:
	ll _num;
	 Modint() : _num() { _num = 0; }
	 Modint(ll x) : _num() { _num = x % MOD; if(_num < 0) _num += MOD; }
	inline  Modint operator= (int x){ _num = x % MOD; if(_num<0) _num += MOD; return *this; }
	inline  Modint operator= (ll x){ _num = x % MOD; if(_num<0) _num += MOD; return *this; }
	inline  Modint operator= (Modint x){ _num = x._num; return *this; }
	inline  Modint operator+ (int x){ return Modint(_num + x); }
	inline  Modint operator+ (ll x){ return Modint(_num + x); }
	inline  Modint operator+ (Modint x){ ll a = _num + x._num; if(a >= MOD) a -= MOD; return Modint{a}; }
	inline  Modint operator+=(int x){ _num += x; _num %= MOD; if(_num < 0) _num += MOD; return *this; }
	inline  Modint operator+=(ll x){ _num += x; _num %= MOD; if(_num < 0) _num += MOD; return *this; }
	inline  Modint operator+=(Modint x){ _num += x._num; if(_num >= MOD) _num -= MOD; return *this; }
	inline  Modint operator++(){ _num++; if(_num == MOD) _num = 0; return *this; }
	inline  Modint operator- (int x){ return Modint(_num - x); }
	inline  Modint operator- (ll x){ return Modint(_num - x); }
	inline  Modint operator- (Modint x){ ll a = _num - x._num; if(a < 0) a += MOD; return Modint{a}; }
	inline  Modint operator-=(int x){ _num -= x; _num %= MOD; if(_num < 0) _num += MOD; return *this; }
	inline  Modint operator-=(ll x){ _num -= x; _num %= MOD; if(_num < 0) _num += MOD; return *this; }
	inline  Modint operator-=(Modint x){ _num -= x._num; if(_num < 0) _num += MOD; return *this; }
	inline  Modint operator--(){ _num--; if(_num == -1) _num = MOD - 1; return *this; }
	inline  Modint operator* (int x){ return Modint(_num * (x % MOD)); }
	inline  Modint operator* (ll x){ return Modint(_num * (x % MOD)); }
	inline  Modint operator* (Modint x){ return Modint{_num * x._num % MOD}; }
	inline  Modint operator*=(int x){ _num *= Modint(x); _num %= MOD; return *this; }
	inline  Modint operator*=(ll x){ _num *= Modint(x); _num %= MOD; return *this; }
	inline  Modint operator*=(Modint x){ _num *= x._num; _num %= MOD; return *this; }
	inline  Modint operator/ (int x){ return Modint(_num * invmod(Modint(x), MOD)); }
	inline  Modint operator/ (ll x){ return Modint(_num * invmod(Modint(x), MOD)); }
	inline  Modint operator/ (Modint x){ return Modint{_num * invmod(x._num, MOD) % MOD}; }
	inline  Modint operator/=(int x){ _num *= invmod(Modint(x), MOD); _num %= MOD; return *this; }
	inline  Modint operator/=(ll x){ _num *= invmod(Modint(x), MOD); _num %= MOD; return *this; }
	inline  Modint operator/=(Modint x){ _num *= invmod(x._num, MOD); _num %= MOD; return *this; }
	inline  Modint pow(ll x){ ll i = 1; Modint ans = 1, cnt = *this; while(i <= x){ if(x & i){ ans *= cnt; x ^= i; } cnt *= cnt; i *= 2; } return ans; }
	inline  operator ll() const { return _num; }
};
inline std::istream& operator>>(std::istream& s, Modint& x){ s >> x._num; return s; }
vector<Modint> fac(1, 1), inv(1, 1);
inline void reserve(size_t a){
	if(fac.size() >= a) return;
	if(a < fac.size() * 2) a = fac.size() * 2;
	if(a >= MOD) a = MOD;
	while(fac.size() < a) fac.push_back(fac.back() * ll(fac.size()));
	inv.resize(fac.size());
	inv.back() = Modint(1) / fac.back();
	for(ll i = inv.size() - 1; !inv[i - 1]; i--) inv[i - 1] = inv[i] * i;
}
inline Modint factorial(ll n){ if(n < 0) return 0; reserve(n + 1); return fac[n]; }
inline Modint nPk(ll n, ll k){ if(k < 0 || n < k) return 0; reserve(n + 1); return fac[n] * inv[n - k]; }
inline Modint nCk(ll n, ll k){ if(k < 0 || n < k) return 0; reserve(n + 1); return fac[n] * inv[k] * inv[n - k]; }
inline Modint nHk(ll n, ll k){ return nCk(n + k - 1, k); } //n種類のものから重複を許してk個選ぶ=玉k個と仕切りn-1個

template< class T >
class Matrix {
public:
	vector< vector< T > > A;

	Matrix() {}

	Matrix(size_t n, size_t m) : A(n, vector< T >(m, 0)) {}

	Matrix(size_t n) : A(n, vector< T >(n, 0)) {};

	size_t height() const {
		return (A.size());
	}

	size_t width() const {
		return (A[0].size());
	}

	inline const vector< T > &operator[](ll k) const {
		return (A.at(k));
	}

	inline vector< T > &operator[](ll k) {
		return (A.at(k));
	}

	static Matrix E(size_t n) {
		Matrix mat(n);
		for(size_t i = 0; i < n; i++) mat[i][i] = 1;
		return (mat);
	}

	Matrix &operator+=(const Matrix &B) {
		size_t n = height(), m = width();
		assert(n == B.height() && m == B.width());
		for(size_t i = 0; i < n; i++)
			for(size_t j = 0; j < m; j++)
				(*this)[i][j] += B[i][j];
		return (*this);
	}

	Matrix &operator-=(const Matrix &B) {
		size_t n = height(), m = width();
		assert(n == B.height() && m == B.width());
		for(size_t i = 0; i < n; i++)
			for(size_t j = 0; j < m; j++)
				(*this)[i][j] -= B[i][j];
		return (*this);
	}

	Matrix &operator*=(const Matrix &B) {
		size_t n = height(), m = B.width(), p = width();
		assert(p == B.height());
		vector< vector< T > > C(n, vector< T >(m, 0));
		for(size_t i = 0; i < n; i++)
			for(size_t j = 0; j < m; j++)
				for(size_t k = 0; k < p; k++)
					C[i][j] = (C[i][j] + (*this)[i][k] * B[k][j]);
		A.swap(C);
		return (*this);
	}

	Matrix &operator^=(long long k) {
		Matrix B = Matrix::E(height());
		while(k > 0) {
			if(k & 1) B *= *this;
			*this *= *this;
			k >>= 1LL;
		}
		A.swap(B.A);
		return (*this);
	}

	Matrix operator+(const Matrix &B) const {
		return (Matrix(*this) += B);
	}

	Matrix operator-(const Matrix &B) const {
		return (Matrix(*this) -= B);
	}

	Matrix operator*(const Matrix &B) const {
		return (Matrix(*this) *= B);
	}

	Matrix operator^(const long long k) const {
		return (Matrix(*this) ^= k);
	}

	friend ostream &operator<<(ostream &os, Matrix &p) {
		size_t n = p.height(), m = p.width();
		for(size_t i = 0; i < n; i++) {
			os << "[";
			for(size_t j = 0; j < m; j++) {
				os << p[i][j] << (j + 1 == m ? "]\n" : ",");
			}
		}
		return (os);
	}


	T determinant() {
		Matrix B(*this);
		assert(width() == height());
		T ret = 1;
		for(size_t i = 0; i < width(); i++) {
			ll idx = -1;
			for(size_t j = i; j < width(); j++) {
				if(B[j][i] != 0) idx = j;
			}
			if(idx == -1) return (0);
			if(i != idx) {
				ret *= -1;
				swap(B[i], B[idx]);
			}
			ret *= B[i][i];
			T vv = B[i][i];
			for(size_t j = 0; j < width(); j++) {
				B[i][j] /= vv;
			}
			for(size_t j = i + 1; j < width(); j++) {
				T a = B[j][i];
				for(size_t k = 0; k < width(); k++) {
					B[j][k] -= B[i][k] * a;
				}
			}
		}
		return (ret);
	}
};

/*-----8<-----library-----8<-----*/

const ll L_MAX = 1e18;
const ll A_MAX = 1e18;
const ll B_MAX = 1e18;
const ll M_MAX = 1e9;

ll L, a, b, M;

bool isOK(ll index,ll keta){
	if(to_string(a+b*index).size()<=keta)return true;
	return false;
}

void solve() {
	scanf("%lld%lld%lld%lld", &L, &a, &b, &MOD);

	vector<ll> ketarange(19,0);
	repeq(keta,18){
		ll left=ketarange[keta-1],right=L;
		while(right-left>1){
			ll mid=(left+right)/2;
			if(isOK(mid,keta))left=mid;
			else right=mid;
		}
		ketarange[keta]=left;
	}
	ketarange[0]=-1;
	debug(ketarange);

	Matrix<Modint> A=Matrix<Modint>::E(3);
	for(ll keta=18;keta>=1;keta--){
		ll ketapow=ketarange[keta]-ketarange[keta-1];
		Matrix<Modint> X(3,3);
		X[0]={pow(10,keta), 1, 0};
		X[1]={0, 1, b};
		X[2]={0, 0, 1};
		X^=ketapow;
		A*=X;
	}

	Matrix<Modint> B(3,1);
	B[0][0]=0;
	B[1][0]=a;
	B[2][0]=1;
	A*=B;

	debug(A);
	p(A[0][0]);
}

// https://atcoder.jp/contests/abc129/tasks/abc129_f
signed main() {
	solve();
	return 0;
}


Measured memory_bytes: 256