// 2020-08-12 22:31:04
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

int mod = 1;
struct mint {
  ll val;
  mint(ll v = 0) noexcept : val(v % mod) {
    if (val < 0) val += mod;
  }
  mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  mint operator ~ () const noexcept {
    ll a = this->val, b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += mod;
    u %= mod;
    return u;
  }
  mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += mod;
    val -= rhs.val;
    return *this;
  }
  mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % mod;
    return *this;
  }
  mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % mod;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

using M = vector<vector<mint> >;

ll l, a, b, pw10[30], sumc[30];
mint modpw10[30];

M matmul(M x, M y) {
  M res(3, vector<mint>(3));
  rep(i, 3) rep(j, 3) rep(k, 3) {
    res[i][j] += x[i][k] * y[k][j];
  }
  return res;
}

M matpow(int d, ll n) {
  M res(3, vector<mint>(3)), cur(3, vector<mint>(3));
  rep(i, 3) res[i][i] = 1;
  cur[0][0] = modpw10[d];
  cur[1][0] = 1;
  cur[1][1] = 1;
  cur[2][1] = b;
  cur[2][2] = 1;
  while(n > 0) {
    if(n&1) {
      res = matmul(res, cur);
    }
    cur = matmul(cur, cur);
    n >>= 1;
  }
  return res;
}

void answer() {
  cin >> l >> a >> b >> mod;
  pw10[0] = 1;
  modpw10[0] = pw10[0];
  REPC(d, 1, 18) {
    pw10[d] = pw10[d-1] * 10;
    modpw10[d] = pw10[d];
  }
  sumc[0] = 0;
  REPC(d, 1, 18) {
    ll s = -1, t = l;
    while(s + 1 < t) {
      ll x = (s + t) / 2;
      if(a + b * x < pw10[d]) s = x;
      else t = x;
    }
    sumc[d] = s + 1;
  }
  mint x = 0, s = a;
  REPC(d, 1, 18) {
    ll n = sumc[d] - sumc[d-1];
    M mat = matpow(d, n);
    mint px = x, ps = s;
    x = px * mat[0][0] + ps * mat[1][0] + mat[2][0];
    s = px * mat[0][1] + ps * mat[1][1] + mat[2][1];
  }
  cout << x << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3592