#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

struct ModInt {
 private:
  static int64 M;
  int64 x;
 public:
  static void SetMod(int64 mod) {
    M = mod;
  }
  ModInt(int64 input_x) : x(input_x % M) {}
  ModInt() : x(0) {}
  int64 Value() const { return x; }
  inline ModInt operator+(ModInt o) const {
    ModInt r(*this); r += o; return r;
  }
  inline ModInt operator-(ModInt o) const {
    ModInt r(*this); r -= o; return r;
  }
  inline ModInt operator* (ModInt o) const {
    ModInt r(*this); r *= o; return r;
  }
  inline void operator+= (ModInt o) { x = (x + o.x) % M; }
  inline void operator-= (ModInt o) { x = (x + M - o.x) % M; }
  inline void operator*= (ModInt o) { x = (x * o.x) % M; }
};
int64 ModInt::M = 1;  // Do not forget to add this line.

template<typename T>
vector<vector<T>> operator*(
    const vector<vector<T>>& a1, const vector<vector<T>>& a2) {
  int n = a1.size();
  int m = a1[0].size();
  if (a2.size() != m) {
    cerr << "Matrix dimensions don't match for multiplication!" << endl;
    exit(1);
  }
  int l = a2[0].size();
  vector<vector<T>> result(n, vector<T>(l));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        result[i][j] += a1[i][k] * a2[k][j];
      }
    }
  }
  return result;
}

template<typename T>
vector<T> operator*(const vector<vector<T>>& matrix, const vector<T>& v) {
  int n = matrix.size();
  int m = matrix[0].size();
  if (v.size() != m) {
    cerr << "Matrix and vector dimensions don't match for multiplication!"
         << endl;
    exit(1);
  }
  vector<T> result(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      result[i] += matrix[i][j] * v[j];
    }
  }
  return result;
}

template<typename T>
vector<vector<T>> MatrixPower(const vector<vector<T>>& matrix, int64 p) {
  int n = matrix.size();
  if (p == 0) {
    vector<vector<T>> return_value(n, vector<T>(n));
    for (int i = 0; i < n; i++) {
      return_value[i][i] = 1;
    }
    return return_value;
  } else if (p % 2 == 1) {
    return matrix * MatrixPower(matrix, p - 1);
  } else {
    auto m = MatrixPower(matrix, p / 2);
    return m * m;
  }
}

void DumpMatrix(const vector<vector<ModInt>> matrix) {
  for (const auto& row : matrix) {
    for (int i = 0; i < row.size(); i++) {
      if (i > 0) cout << " ";
      cout << row[i].Value();
    }
    cout << endl;
  }
}

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

  int64 length, s, d, mod;
  cin >> length >> s >> d >> mod;
  ModInt::SetMod(mod);

  int64 r = 10;
  ModInt answer = ModInt(0);
  bool initialized = false;
  while (true) {
    if (s >= r) {
      r *= 10;
      continue;
    }
    int64 current_length = min(length, (r - 1 - s) / d + 1);
    // cout << "r: " << r << endl;
    // cout << "current_length: " << current_length << endl;

    // Do
    // cout << s << " " << current_length << endl;
    vector<vector<ModInt>> matrix {
      {r, d, s},
      {0, 1, 1},
      {0, 0, 1}
    };
    auto power_result = MatrixPower(matrix, current_length);
    auto vector_result = power_result * vector<ModInt>({answer, 0, 1});
    answer = vector_result[0];
    // cout << "answer: " << answer.Value() << endl;

    // To the next level.
    s += d * current_length;
    length -= current_length;
    r *= 10;
    if (length == 0) break;
  }
  cout << answer.Value() << endl;
}


Measured memory_bytes: 256