#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

template< class T >
struct Matrix {
  const size_t H, W;
  vector< vector< T > > A;
  ll mod;
  Matrix() {}
  Matrix(size_t n, size_t m, int mod) : H(n), W(m), A(H, vector< T >(W, 0)), mod(mod) {}
  Matrix(size_t n, size_t m) : H(n), W(m), A(H, vector< T >(W, 0)) {}
  Matrix(size_t n) : H(n), W(n), A(H, vector< T >(W, 0)) {};
  size_t height() const { return H; }
  size_t width() const { return W; }
  inline const vector< T > &operator[](int k) const { return (A.at(k)); }
  inline vector< T > &operator[](int k) { return (A.at(k)); }
  static Matrix I(size_t n) {
    Matrix mat(n);
    for(int i = 0; i < n; i++) mat[i][i] = 1;
    return (mat);
  }

  Matrix &operator%=(int m) {
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++)
        (*this)[i][j] %= m;
    return (*this);
  }

  Matrix &operator+=(const Matrix &B) {
    assert(H == B.H && W == B.W);
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++) {
        (*this)[i][j] += (B[i][j]%mod);
        (*this)[i][j] %= mod;
      }
    return (*this);
  }

  Matrix &operator-=(const Matrix &B) {
    assert(H == B.H && W == B.W);
    for(int i = 0; i < H; i++)
      for(int j = 0; j < W; j++) {
        (*this)[i][j] -= (B[i][j]%mod);
        (*this)[i][j] += mod;
        (*this)[i][j] %= mod;
      }
    return (*this);
  }

  Matrix &operator*=(const Matrix &B) {
    assert(W == B.H);
    vector< vector< T > > C(H, vector< T >(B.W, 0));
    for(int i = 0; i < H; i++)
      for(int j = 0; j < B.W; j++)
        for(int k = 0; k < W; k++) {
          C[i][j] += (((*this)[i][k]%mod) * (B[k][j]%mod))%mod;
          assert(C[i][j] >= 0);
          C[i][j] %= mod;
        }
    A.swap(C);
    return (*this);
  }

  Matrix &operator^=(long long k) {
    Matrix B = Matrix::I(H);
    B.mod = mod;
    while(k > 0) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1LL;
    }
    A.swap(B.A);
    return (*this);
  }

  Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); }
  Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); }
  Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); }
  Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); }

  friend ostream &operator<<(ostream &os, Matrix &p) {
    for(int i = 0; i < p.H; i++) {
      for(int j = 0; j < p.W; j++) {
        os << p[i][j] << (j + 1 == p.W ? "\n" : " ");
      }
    }
    return (os);
  }
};

using matrix = Matrix<ll>;

ll ld0[19];
// その桁数の要素数を格納する
ll ld[19];
int main() {
  ll l, a, b, m;
  cin >> l >> a >> b >> m;

  for (int i = 0; i <= 18; ++i) {
    ll x = pow(10, i);
    if (x <= a) continue;
    ll d = (x-a+b-1)/b;
    if (d > l) ld0[i] = l;
    else ld0[i] = d;
    ld[i] = ld0[i];
    if (i > 0) ld[i] -= ld0[i-1];
    // cout << i << " " << ld[i] << endl;
  }
  matrix q(3, 3, m);
  q[0][0] = 1; q[1][1] = 1; q[2][2] = 1;
  for (int i = 1; i <= 18; ++i) {
    matrix p(3, 3, m);
    p[0][0] = pow(10, i); p[0][1] = 0; p[0][2] = 0;
    p[1][0] = 1;          p[1][1] = 1; p[2][2] = 0;
    p[2][0] = 0;          p[2][1] = b; p[2][2] = 1;
    p[0][0] %= m;
    p[2][1] %= m;
    p ^= ld[i];
    q *= p;
    // cout << "mat " << i << endl;
    // cout << p[0][0] << " " << p[0][1] << " " << p[0][2] << endl;
    // cout << p[1][0] << " " << p[1][1] << " " << p[1][2] << endl;
    // cout << p[2][0] << " " << p[2][1] << " " << p[2][2] << endl;
  }
  ll ans = (q[1][0]*(a%m)%m) + q[2][0];
  ans %= m;
  cout << ans << endl;
}



Measured memory_bytes: 256