#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

ll l, A, B;

typedef vector<ll> vec;
typedef vector<vector<ll> > mat;
int m;
vec matmul(vec &dp, mat &mt) {
  vec ret(m, 0);
  rep(i, m) rep(j, m) {
    // cout << 1 << " " << ret[i] << " " << mt[i][j] << " " << dp[j] << " " << mt[i][j] % mod * dp[j] % mod << endl;
    add(ret[i], mt[i][j] % mod * (dp[j] % mod) % mod); // debuged
  }
  return ret;
}
mat update(mat &mt) {
  mat ret(m, vec(m, 0));
  rep(i, m) rep(j, m) rep(k, m) {
    // cout << 2 << " " << ret[i][j] << " " << mt[i][k] << " " << mt[k][j] << " " << mt[i][k] % mod * mt[k][j] % mod << endl;
    add(ret[i][j], mt[i][k] % mod * (mt[k][j] % mod) % mod);
  }
  return ret;
}
// mt[0] : 1 "列"目
void matpow(vec &dp, mat &mt, ll k) {
  m = sz(dp);
  while (k) {
    if (k & 1) dp = matmul(dp, mt);
    mt = update(mt);
    k >>= 1;
  }
}

int f(ll x) {
  int c = 0;
  while (x) {
    x /= 10;
    c++;
  }
  return c;
}

// pdf editorial
void solve() {
  int M;
  cin >> l >> A >> B >> M;
  mod = M;
  vec v{0, A, 1};
  // cout << v << endl;

  // 要素数が二分探索でうまくいかない
  // とりあえず過去のコードで行列累乗以外は
  ll last = A + B * (l - 1);
  ll ten = 1;
  rep(i, 19) { // 後ろの 0 の個数
    ten *= 10;
    ll l = ten / 10, r = ten - 1; // [1, 9], [10, 99], 
    ll na, nlast; // 今見てる桁数の初項, 末項
    ll nl; // 項数
    if (last < l) continue; // 初項が本当の末項より大きい
    if (r < A) continue; // 末項が本当の初項より小さい
    
    if (l <= A) na = A; // 初項を本当の初項に
    // a + b * i ≥ l
    // i = (l - a) / b の切り上げ
    else na = (l - A + (B - 1)) / B * B + A;
    
    if (last <= r) nlast = last; // 末項を本当の末項に
    // a + b * i ≤ r
    else nlast = (r - A) / B * B + A;
    
    nl = (nlast - na) / B + 1;
    mat mt{{pow(10LL, i + 1), 1, 0}, {0, 1, B}, {0, 0, 1}};
    matpow(v, mt, nl);
  }
  cout << v[0] << endl;
}


Measured memory_bytes: 256