#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
constexpr int INF = 1 << 30;
constexpr long long INFL = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-9;
using lint = long long;

using namespace std;

class VariableModInt {
  long long n_;
  static long long &mod() {
    static long long mod_ = 1;
    return mod_;
  }

  public:
  VariableModInt(const long long num = 0) : n_(num % get_mod()) {}
  long long &value() { return n_; }
  const long long &value() const { return n_; }
  bool operator==(const VariableModInt &r) const { return (*this).n_ == r.n_; }
  bool operator!=(const VariableModInt &r) const { return (*this).n_ != r.n_; }
  bool operator<(const VariableModInt &r) const { return (*this).n_ < r.n_; }
  bool operator>(const VariableModInt &r) const { return (*this).n_ > r.n_; }
  bool operator<=(const VariableModInt &r) const { return (*this).n_ <= r.n_; }
  bool operator>=(const VariableModInt &r) const { return (*this).n_ >= r.n_; }
  VariableModInt operator+(const VariableModInt &r) const { return VariableModInt(*this) += r; }
  VariableModInt operator-(const VariableModInt &r) const { return VariableModInt(*this) -= r; }
  VariableModInt operator*(const VariableModInt &r) const { return VariableModInt(*this) *= r; }
  VariableModInt operator/(const VariableModInt &r) const { return VariableModInt(*this) /= r; }
  VariableModInt &operator+=(const VariableModInt &r) {
    n_ += r.n_;
    if (n_ >= get_mod()) n_ -= get_mod();
    return *this;
  }
  VariableModInt &operator-=(const VariableModInt &r) {
    if (n_ < r.n_) n_ += get_mod();
    n_ -= r.n_;
    return *this;
  }
  VariableModInt &operator*=(const VariableModInt &r) {
    n_ = n_ * r.n_ % get_mod();
    return *this;
  }
  VariableModInt &operator/=(VariableModInt r) {
    long long exp = get_mod() - 2;
    while (exp) {
      if (exp & 2) *this *= r;
      r *= r;
      exp /= 2;
    }
    return *this;
  }
  operator int() const { return n_; }
  operator long long() const { return n_; }
  operator double() const { return n_; }
  static void set_mod(const long long mod_num) { mod() = mod_num; }
  static long long get_mod() { return mod(); }
  friend std::ostream &operator<<(std::ostream &os, const VariableModInt &vmi) { return os << vmi.n_; }
};

template <typename T>
class Matrix {
  std::vector<std::vector<T>> mat_;
  int h_, w_;

  public:
  Matrix(void) {}
  Matrix(size_t n) : mat_(n, std::vector<T>(n)), h_(n), w_(n) {}
  Matrix(size_t height, size_t width) : mat_(height, std::vector<T>(width)), h_(height), w_(width) {}
  Matrix(size_t height, size_t width, T initial) : mat_(height, std::vector<T>(width, initial)), h_(height), w_(width) {}
  Matrix(std::initializer_list<std::initializer_list<T>> list_2d) : h_(list_2d.size()), w_(list_2d.begin()->size()) {
    mat_.resize(h_);
    for (auto vitr = mat_.begin(), litr = list_2d.begin(); vitr != mat_.end(); ++vitr, ++litr) {
      assert(w_ == litr->size());
      vitr->assign(litr->begin(), litr->end());
    }
  }
  const std::vector<T> &operator[](size_t k) const { return mat_[k]; }
  std::vector<T> &operator[](size_t k) { return mat_[k]; }
  Matrix operator+(const Matrix &rmat) const { return (Matrix(*this) += rmat); }
  Matrix operator-(const Matrix &rmat) const { return (Matrix(*this) -= rmat); }
  Matrix operator*(const Matrix &rmat) const { return (Matrix(*this) *= rmat); }
  Matrix operator*(const T &n) const { return (Matrix(*this) *= n); }
  friend Matrix operator*(const T &t, const Matrix &rmat) { return (Matrix(rmat) *= t); }
  Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); }
  Matrix &operator+=(const Matrix &rmat) {
    assert(h_ == rmat.h_ && w_ == rmat.w_);
    for (int i = 0; i < h_; ++i) {
      for (int j = 0; j < w_; ++j) {
        mat_[i][j] += rmat[i][j];
      }
    }
    return *this;
  }
  Matrix &operator-=(const Matrix &rmat) {
    assert(h_ == rmat.h_ && w_ == rmat.w_);
    for (int i = 0; i < h_; ++i) {
      for (int j = 0; j < w_; ++j) {
        mat_[i][j] -= rmat[i][j];
      }
    }
    return *this;
  }
  Matrix &operator*=(const Matrix &rmat) {
    assert(w_ == rmat.h_);
    std::vector<std::vector<T>> nmat(h_, std::vector<T>(rmat.w_));
    for (int i = 0; i < h_; ++i) {
      for (int k = 0; k < w_; ++k) {
        for (int j = 0; j < rmat.w_; ++j) {
          nmat[i][j] += mat_[i][k] * rmat[k][j];
        }
      }
    }
    mat_.swap(nmat);
    w_ = rmat.w_;
    return *this;
  }
  Matrix &operator*=(const int n) {
    for (int i = 0; i < h_; ++i) {
      for (int j = 0; j < w_; ++j) {
        mat_[i][j] *= n;
      }
    }
    return *this;
  }
  Matrix &operator^=(long long k) {
    assert(h_ == w_);
    Matrix<T> imat(h_);
    for (int i = 0; i < h_; ++i) imat[i][i] = 1;
    while (k > 0) {
      if (k & 1) imat *= *this;
      *this *= *this;
      k >>= 1;
    }
    mat_.swap(imat.mat_);
    return *this;
  }
  int height(void) { return h_; }
  int width(void) { return w_; }
  T max_value() {
    T maxi = *std::max_element(mat_[0].begin(), mat_[0].end());
    for (int i = 1; i < h_; ++i) maxi = std::max(maxi, *std::max_element(mat_[i].begin(), mat_[i].end()));
    return maxi;
  }
  T min_value() {
    T mini = *std::min_element(mat_[0].begin(), mat_[0].end());
    for (int i = 1; i < h_; ++i) mini = std::min(mini, *std::min_element(mat_[i].begin(), mat_[i].end()));
    return mini;
  }
  Matrix transpose(void) {
    std::vector<std::vector<T>> nmat(w_, std::vector<T>(h_));
    for (int i = 0; i < h_; ++i) {
      for (int j = 0; j < w_; ++j) {
        nmat[i][j] = mat_[j][i];
      }
    }
    return nmat;
  }
  T determinant(void) {
    assert(h_ == w_);
    std::vector<std::vector<double>> nmat(h_);
    for (int i = 0; i < h_; ++i) nmat[i].assign(mat_[i].begin(), mat_[i].end());
    double ret = 1;
    for (int i = 0; i < h_; ++i) {
      int idx = -1;
      for (int j = i; j < h_; ++j) {
        if (nmat[j][i] != 0) {
          idx = j;
          break;
        }
      }
      if (idx == -1) return 0;
      if (i != idx) {
        ret *= -1;
        std::swap(nmat[i], nmat[idx]);
      }
      double ratio = nmat[i][i];
      ret *= ratio;
      for (int j = 0; j < h_; ++j) nmat[i][j] /= ratio;
      for (int j = i + 1; j < h_; ++j) {
        T n = nmat[j][i];
        for (int k = 0; k < h_; ++k) {
          nmat[j][k] -= nmat[i][k] * n;
        }
      }
    }
    return T(ret);
  }
  friend ostream &operator<<(ostream &os, Matrix &mat) {
    int digit = std::log10((double)mat.max_value()) + 2;
    for (int i = 0; i < mat.h_; ++i) {
      os << "[";
      for (int j = 0; j < mat.w_; ++j) {
        os << std::setw(digit) << mat[i][j] << (j + 1 == mat.w_ ? " ]\n" : ",");
      }
    }
    return os;
  }
  // External
  T rational_determinant(void);
};

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  lint l, a, b, m;
  cin >> l >> a >> b >> m;
  vector<lint> k;
  k.push_back(0);
  lint x = 1;

  rep1 (i, 18) {
    x *= 10;
    if (x - a < 0) {
      k.push_back(0);
    } else {
      lint t = (x - 1 - a) / b + 1;
      if (t > l) {
        k.push_back(l);
        break;
      }
      k.push_back(t);
    }
  }
  VariableModInt::set_mod(m);
  Matrix<VariableModInt> product_mat{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  rrep1(i, k.size() - 1) {
    if (k[i] - k[i - 1] <= 0) continue;
    Matrix<VariableModInt> mat{{1, 0, b}, {1, x, 0}, {0, 0, 1}};
    mat ^= k[i] - k[i - 1];
    product_mat *= mat;
    x /= 10;
  }
  Matrix<VariableModInt> init{{a}, {0}, {1}};
  product_mat *= init;
  cout << product_mat[1][0] << endl;
  return 0;
}

Measured memory_bytes: 256