#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
const int MF = 100005, MOD = 1000007;

unsigned MODULO = 1e9 + 7;
template <unsigned M, unsigned T>
struct mod_int
{
  constexpr static unsigned TABLE_SIZE = T;
  signed x;

  mod_int() : x(0) {}

  mod_int(long long y)
      : x(static_cast<signed>(y >= 0 ? y % MODULO : MODULO - (-y) % MODULO)) {}

  mod_int(int y) : x(y >= 0 ? y % MODULO : MODULO - (-y) % MODULO) {}

  mod_int &operator+=(const mod_int &rhs)
  {
    if ((x += rhs.x) >= MODULO)
      x -= MODULO;
    return *this;
  }

  mod_int &operator-=(const mod_int &rhs)
  {
    if ((x += MODULO - rhs.x) >= MODULO)
      x -= MODULO;
    return *this;
  }

  mod_int &operator*=(const mod_int &rhs)
  {
    x = static_cast<signed>(1LL * x * rhs.x % MODULO);
    return *this;
  }

  mod_int &operator/=(const mod_int &rhs)
  {
    x = static_cast<signed>((1LL * x * rhs.inv().x) % MODULO);
    return *this;
  }

  mod_int operator-() const { return mod_int(-x); }

  mod_int operator+(const mod_int &rhs) const { return mod_int(*this) += rhs; }

  mod_int operator-(const mod_int &rhs) const { return mod_int(*this) -= rhs; }

  mod_int operator*(const mod_int &rhs) const { return mod_int(*this) *= rhs; }

  mod_int operator/(const mod_int &rhs) const { return mod_int(*this) /= rhs; }

  bool operator<(const mod_int &rhs) const { return x < rhs.x; }

  mod_int pow(long long t) const
  {
    assert(!(x == 0 && t == 0));
    mod_int e = *this, res = mod_int(1);
    for (; t; e *= e, t >>= 1)
      if (t & 1)
        res *= e;
    return res;
  }
};

template <int M, unsigned F>
std::ostream &operator<<(std::ostream &os, const mod_int<M, F> &rhs)
{
  return os << rhs.x;
}

template <int M, unsigned F>
std::istream &operator>>(std::istream &is, mod_int<M, F> &rhs)
{
  long long s;
  is >> s;
  rhs = mod_int<M, F>(s);
  return is;
}

template <int M, unsigned F>
bool operator==(const mod_int<M, F> &lhs, const mod_int<M, F> &rhs)
{
  return lhs.x == rhs.x;
}

template <int M, unsigned F>
bool operator!=(const mod_int<M, F> &lhs, const mod_int<M, F> &rhs)
{
  return !(lhs == rhs);
}

using mint = mod_int<MOD, MF>;
template <typename K>
struct Matrix
{
  typedef vector<K> arr;
  typedef vector<arr> mat;
  mat dat;

  Matrix(size_t r, size_t c) : dat(r, arr(c, K())) {}
  Matrix(mat dat) : dat(dat) {}

  size_t size() const { return dat.size(); }
  bool empty() const { return size() == 0; }
  arr &operator[](size_t k) { return dat[k]; }
  const arr &operator[](size_t k) const { return dat[k]; }

  static Matrix cross(const Matrix &A, const Matrix &B)
  {
    Matrix res(A.size(), B[0].size());
    for (int i = 0; i < (int)A.size(); i++)
      for (int j = 0; j < (int)B[0].size(); j++)
        for (int k = 0; k < (int)B.size(); k++)
          res[i][j] += A[i][k] * B[k][j];
    return res;
  }

  static Matrix identity(size_t n)
  {
    Matrix res(n, n);
    for (int i = 0; i < (int)n; i++)
      res[i][i] = K(1);
    return res;
  }

  Matrix pow(long long n) const
  {
    Matrix a(dat), res = identity(size());
    while (n)
    {
      if (n & 1)
        res = cross(res, a);
      a = cross(a, a);
      n >>= 1;
    }
    return res;
  }
};
void solve(long long L, long long A, long long B, long long M)
{
  // (L-1) * B + A
  // 桁数kどこからどこまでか

  MODULO = M;
  lli p = 1;
  mint ret = 0;
  Matrix<mint> arr({{ret}, {A}, {1}});
  lli cur = 0;
  for (lli k = 1; k <= 18; k++)
  {
    lli up = L, low = 0;
    while (up - low > 1)
    {
      lli mid = (up + low) / 2;
      (mid * B + A < 10 * p ? low : up) = mid;
    }
    // [cur, up) が桁数k以下
    int pow = 10;
    Matrix<mint> mat({{p * 10, 1, 0}, {0, 1, B}, {0, 0, 1}});
    // cerr << up << " " << low << " " << cur << endl;
    arr = Matrix<mint>::cross(mat.pow(up - cur), arr);
    p *= 10;
    cur = up;
  }
  cout << arr[0][0].x << endl;
}

signed main()
{
  long long L;
  scanf("%lld", &L);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long M;
  scanf("%lld", &M);
  solve(L, A, B, M);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 256