#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()) {}
  const long long &value() const { return n_; }
  bool operator==(const VariableModInt &r) const { return this->n_ == r.n_; }
  bool operator==(const long long &r) const { return this->n_ == r; }
  bool operator!=(const VariableModInt &r) const { return this->n_ != r.n_; }
  bool operator!=(const long long &r) const { return this->n_ != r; }
  bool operator<(const VariableModInt &r) const { return this->n_ < r.n_; }
  bool operator<(const long long &r) const { return this->n_ < r; }
  bool operator>(const VariableModInt &r) const { return this->n_ > r.n_; }
  bool operator>(const long long &r) const { return this->n_ > r; }
  bool operator<=(const VariableModInt &r) const { return this->n_ <= r.n_; }
  bool operator<=(const long long &r) const { return this->n_ <= r; }
  bool operator>=(const VariableModInt &r) const { return this->n_ >= r.n_; }
  bool operator>=(const long long &r) const { return this->n_ >= 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) const { return VariableModInt(*this) /= r; }
  VariableModInt operator+(const long long &r) const { return VariableModInt(*this) += VariableModInt(r); }
  VariableModInt operator-(const long long &r) const { return VariableModInt(*this) -= VariableModInt(r); }
  VariableModInt operator*(const long long &r) const { return VariableModInt(*this) *= VariableModInt(r); }
  VariableModInt operator/(const long long &r) const { return VariableModInt(*this) /= VariableModInt(r); }
  friend VariableModInt operator+(const long long &l, const VariableModInt &r) { return VariableModInt(l) += r; }
  friend VariableModInt operator-(const long long &l, const VariableModInt &r) { return VariableModInt(l) -= r; }
  friend VariableModInt operator*(const long long &l, const VariableModInt &r) { return VariableModInt(l) *= r; }
  friend VariableModInt operator/(const long long &l, const VariableModInt &r) { return VariableModInt(l) /= r; }
  VariableModInt &operator++() { return *this += 1; }
  VariableModInt &operator--() { return *this -= 1; }
  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;
  }
  static void set_mod(const long long mod_num) { mod() = mod_num; }
  static long long get_mod() { return mod(); }
  explicit operator int() const { return n_; }
  explicit operator long long() const { return n_; }
  explicit operator double() const { return n_; }
  friend std::istream &operator>>(std::istream &is, VariableModInt &r) {
    is >> r.n_;
    r.n_ %= r.get_mod();
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const VariableModInt &r) { return os << r.n_; }
};

template <typename T>
T power(T x, long long n) {
  T ret = 1;
  while (n) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}

using mint = VariableModInt;

mint pow_10(lint k) {
  static unordered_map<lint, mint> memory{{0, 1}};
  if (memory.find(k) != memory.end()) return memory[k];
  if (k & 1) {
    return memory[k] = pow_10(k - 1) * 10;
  } else {
    mint x = pow_10(k / 2);
    return memory[k] = x * x;
  }
}

mint f(lint i, int k) {
  static map<tuple<lint, int>, mint> memory;
  if (memory.find(pair<lint, int>(i, k)) != memory.end()) return memory[pair<lint, int>(i, k)];
  if (i == 0) return 0;
  if (i & 1) {
    return memory[pair<lint, int>(i, k)] = f(i - 1, k) * pow_10(k) + 1;
  } else {
    return memory[pair<lint, int>(i, k)] = f(i / 2, k) * (pow_10(k * (i / 2)) + 1);
  }
}

mint g(lint i, int k, lint plusi, mint &B) {
  if (i == 0) return 0;
  mint gt;
  if (i & 1) {
    return g(i - 1, k, plusi, B) * pow_10(k) + B * (plusi + i - 1);
  } else {
    return g(i / 2, k, plusi, B) * (pow_10(k * (i / 2)) + 1) + B * (i / 2) * f(i / 2, k);
  }
}

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 = min((x - 1 - a) / b + 1, l);
      k.push_back(t);
      if (t == l) break;
    }
  }
  mint::set_mod(m);
  mint sum = 0, A = a, B = b;
  rep1 (i, k.size() - 1) {
    lint len = k[i] - k[i - 1];
    if (len <= 0) continue;
    sum = sum * power<mint>(pow_10(len), i) + A * f(len, i) + g(len, i, k[i - 1], B);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 384