#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define revrep(i, n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

mat mul_mat(mat &A, mat &B){
  mat res(A.size(), vec(B[0].size()));
  rep(i, A.size())rep(k, B.size())rep(j, B[0].size()){
    res[i][j] = (res[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
  }
  return res;
}
mat pow_mat(mat &A, ll n){
  mat res(A.size(), vec(A.size()));
  rep(i, A.size()) res[i][i] = 1;
  while(n > 0){
    if(n&1) res = mul_mat(res, A);
    A = mul_mat(A, A);
    n >>= 1;
  }
  return res;
}

int main(void){
  ll L, A, B, M;
  ll X = 0;
  cin >> L >> A >> B >> M;
  ll A_ = A, B_ = B;
  MOD = M;
  ll MAX = A_ + B_ * (L - 1);
  A %= MOD; B %= MOD;
  for(int k = 1; k < 19; k++){
    ll comp1 = 1, comp2 = 10;
    rep(i, k-1){
      comp1 *= 10;
      comp2 *= 10;
    }
    comp2--;
    if(comp2 < A_ || MAX < comp1) continue;
    ll s = (comp1 - A_ + B_- 1) / B_;
    ll t = (comp2 - A_) / B_;
    s = max(s, 0LL);
    t = min(t, L-1);
    mat P(3, vec(3));
    P[0][0] = (comp2+1) % MOD; P[0][1] = 1; P[0][2] = 0;
    P[1][0] = 0; P[1][1] = 1; P[1][2] = 1;
    P[2][0] = 0; P[2][1] = 0; P[2][2] = 1;
    P = pow_mat(P, t-s+1);
    X = (P[0][0] * X) % MOD + (P[0][1] * ((A + (B * s) % MOD) % MOD)) % MOD + (P[0][2] * B % MOD);
    X %= MOD;
  }
  cout << (X + MOD) % MOD  << endl;
}


Measured memory_bytes: 256