#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_; }
};

using mint = VariableModInt;

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

mint g(lint i, mint &tenk, lint ten, mint &B, lint plusi) {
  if (i == 0) return 0;
  mint gt;
  if (i & 1) {
    lint bi = i - 1;
    gt = g(bi, tenk, ten, B, plusi);
    gt = gt * ten + B * (plusi + bi);
    tenk *= ten;
  } else {
    lint bi = i / 2;
    mint ctenk(tenk);
    gt = g(bi, tenk, ten, B, plusi);
    gt = gt * (tenk + 1) + B * bi * f(bi, ctenk, ten);
    tenk *= tenk;
  }
  return gt;
}

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);
    }
  }
  mint::set_mod(m);
  mint sum = 0;
  x = 1;
  mint A = a, B = b;
  rep1 (i, k.size() - 1) {
    x *= 10;
    lint len = k[i] - k[i - 1];
    if (len <= 0) continue;
    mint fk = 1, gk = 1;
    auto F = f(len, fk, x);
    auto G = g(len, gk, x, B, k[i - 1]);
    sum = sum * fk + A * F + G;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 384