#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;

class runtime_modint {
  using u64 = std::uint_fast64_t;

  static u64 &mod() {
    static u64 mod_ = 0;
    return mod_;
  }

public:
  u64 a;

  runtime_modint(const u64 x = 0) : a(x % get_mod()) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  runtime_modint operator+(const runtime_modint rhs) const {
    return runtime_modint(*this) += rhs;
  }
  runtime_modint operator-(const runtime_modint rhs) const {
    return runtime_modint(*this) -= rhs;
  }
  runtime_modint operator*(const runtime_modint rhs) const {
    return runtime_modint(*this) *= rhs;
  }
  runtime_modint operator/(const runtime_modint rhs) const {
    return runtime_modint(*this) /= rhs;
  }
  runtime_modint &operator+=(const runtime_modint rhs) {
    a += rhs.a;
    if (a >= get_mod()) {
      a -= get_mod();
    }
    return *this;
  }
  runtime_modint &operator-=(const runtime_modint rhs) {
    if (a < rhs.a) {
      a += get_mod();
    }
    a -= rhs.a;
    return *this;
  }
  runtime_modint &operator*=(const runtime_modint rhs) {
    a = a * rhs.a % get_mod();
    return *this;
  }
  runtime_modint &operator/=(runtime_modint rhs) {
    u64 exp = get_mod() - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  runtime_modint pow(unsigned long n){
    runtime_modint res(1),a=*this;
    while(n){
      if(n%2){
        res*=a;
      }
      a*=a;
      n/=2;
    }
    return res;
  }

  static void set_mod(const u64 x) { mod() = x; }
  static u64 get_mod() { return mod(); }
};
using mint=runtime_modint;
using vec=vector<mint>;
using mat=vector<vec>;

mat mul(mat &a,mat &b)
{
  mat res(a.size(),vec(b[0].size(),0));
  for(int i=0;i<a.size();i++)
  {
    for(int k=0;k<b.size();k++)
    {
      for(int j=0;j<b[0].size();j++)
      {
        res[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
  return res;
}

mat pow(mat &a,unsigned long n)
{
  mat b(a.size(),vec(a.size(),0));
  for(int i=0;i<a.size();i++)
  {
    b[i][i]=1;
  }
  while(n>0)
  {
    if(n&1)b=mul(b,a);
    a=mul(a,a);
    n>>=1;
  }
  return b;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l,a,b,m;cin>>l>>a>>b>>m;
  mint::set_mod(m);
  vector<ll>lb(20);
  unsigned long ks=0;
  rep(i,19){
    ll ti=pow(10,i);
    if((ti-a-1+b)>=0)lb[i]=(ti-a-1+b)/b;
    if(lb[i]>l)lb[i]=l;
  }
  lb[19]=l;
  mint res;
  rrep(d,19){
    ll keta=d+1;
    mint td((ll)pow(10,keta));
    mint s0(a+b*lb[d]);
    mat a=mat(3,vec(3));;
    a={{td,1,0},
       {0,1,(mint)b},
       {0,0,1}};
    mat x={{0},{s0},{1}};
    auto ap=pow(a,lb[d+1]-lb[d]);
    auto y=mul(ap,x);
    mint ten(10);
    res+=y[0][0]*ten.pow(ks);
    ks+=keta*(lb[d+1]-lb[d]);
  }
  cout<<res.value()<<endl;


  return 0;

}


Measured memory_bytes: 256