#include <bits/stdc++.h>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
T modpow(const T x, const T n, const T m) {
  if (n == 0) return 1;
  if (n % 2 == 0) {
    return modpow(x * x % m, n / 2, m);
  } else {
    return x * modpow(x, n - 1, m) % m;
  }
}

namespace ublas = boost::numeric::ublas;

int main() {
  int64_t l, a, b, m;
  std::cin >> l >> a >> b >> m;

  std::vector<int64_t> c(18);

  if (9 < a) {
    c[0] = 0;
  } else {
    c[0] = std::min((9 - a) / b + 1, l);
  }

  {
    int64_t sum = c[0];
    int64_t p = 10;
    for (int64_t i = 1; i < 18; i++) {
      p *= 10;
      const auto max = p - 1;
      if (max < a) {
        c[i] = 0;
      } else {
        c[i] = std::min((max - a) / b + 1, l) - sum;
      }
      sum += c[i];
    }
  }

  ublas::vector<int64_t> vec(3);
  vec(0) = 0;
  vec(1) = a;
  vec(2) = 1;

  ublas::matrix<int64_t> prod(3, 3);
  prod(0, 1) = 0;
  prod(0, 2) = 0;
  prod(1, 0) = 1;
  prod(1, 1) = 1;
  prod(1, 2) = 0;
  prod(2, 0) = 0;
  prod(2, 1) = b;
  prod(2, 2) = 1;

  for (int64_t i = 0; i < 18; i++) {
    if (c[i] != 0) {
      prod(0, 0) = modpow<int64_t>(10, i + 1, m);

      auto tmp = prod;
      ublas::matrix<int64_t> ans(3, 3);
      ans(0, 0) = 1;
      ans(0, 1) = 0;
      ans(0, 2) = 0;
      ans(1, 0) = 0;
      ans(1, 1) = 1;
      ans(1, 2) = 0;
      ans(2, 0) = 0;
      ans(2, 1) = 0;
      ans(2, 2) = 1;

      int64_t j = 1;
      while (j <= c[i]) {
        if ((j & c[i]) != 0) {
          int64_t a1 = (ans(0, 0) % m) * (tmp(0, 0) % m) % m +
                       (ans(0, 1) % m) * (tmp(1, 0) % m) % m +
                       (ans(0, 2) % m) * (tmp(2, 0) % m) % m;
          a1 %= m;
          int64_t a2 = (ans(1, 0) % m) * (tmp(0, 0) % m) % m +
                       (ans(1, 1) % m) * (tmp(1, 0) % m) % m +
                       (ans(1, 2) % m) * (tmp(2, 0) % m) % m;
          a2 %= m;
          int64_t a3 = (ans(2, 0) % m) * (tmp(0, 0) % m) % m +
                       (ans(2, 1) % m) * (tmp(1, 0) % m) % m +
                       (ans(2, 2) % m) * (tmp(2, 0) % m) % m;
          a3 %= m;
          ans = ublas::prod(ans, tmp);
          ans(0, 0) = a1;
          ans(1, 0) = a2;
          ans(2, 0) = a3;
        }
        int64_t t1 = (tmp(0, 0) % m) * (tmp(0, 0) % m) % m +
                     (tmp(0, 1) % m) * (tmp(1, 0) % m) % m +
                     (tmp(0, 2) % m) * (tmp(2, 0) % m) % m;
        t1 %= m;
        int64_t t2 = (tmp(1, 0) % m) * (tmp(0, 0) % m) % m +
                     (tmp(1, 1) % m) * (tmp(1, 0) % m) % m +
                     (tmp(1, 2) % m) * (tmp(2, 0) % m) % m;
        t2 %= m;
        int64_t t3 = (tmp(2, 0) % m) * (tmp(0, 0) % m) % m +
                     (tmp(2, 1) % m) * (tmp(1, 0) % m) % m +
                     (tmp(2, 2) % m) * (tmp(2, 0) % m) % m;
        t3 %= m;
        tmp = ublas::prod(tmp, tmp);
        tmp(0, 0) = t1;
        tmp(1, 0) = t2;
        tmp(2, 0) = t3;
        j <<= 1;
      }

      int64_t v1 = (vec(0) % m) * (ans(0, 0) % m) % m +
                   (vec(1) % m) * (ans(1, 0) % m) % m +
                   (vec(2) % m) * (ans(2, 0) % m) % m;
      v1 %= m;
      vec = ublas::prod(vec, ans);
      vec(0) = v1;
    }
  }
  std::cout << vec(0) % m << std::endl;

  return 0;
}


Measured memory_bytes: 256