#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

int M;

int add(int a, int b) {
	a %= M;
	b %= M;
	return (a + b) % M;
}

int sub(int a, int b) {
	a %= M;
	b %= M;
	return (a - b + M) % M;
}

int mul(int a, int b) {
	a %= M;
	b %= M;
	return (a * b) % M;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res = mul(res, a);
		}
 		a = mul(a, a);
 		b >>= 1;
 	}
 	return res;
}

int lenn(int x) {
	int c = 0;
	while (x > 0) {
		c++;
		x /= 10;
	}
	return c;
}

int src(int nlen, int all, int a, int b) {
	int l = 0;
	int r = all - 1;
	while (r - l > 1) {
		int m = (r + l) >> 1;
		if (lenn(a + (m) * b) <= nlen) l = m;
		else r = m;
	}
	return l;
}

 
struct Matrix {
    int n, m;
    vector<vector<int>> a;
    
    Matrix() {
        n = -1;
        m = -1;
    }
    
    Matrix(int n_, int m_) {
        n = n_;
        m = m_;
        a.resize(n, vector<int> (m));
    }
    
    void set(int i, int j, int val) {
        a[i][j] = val;
    }
    
    friend Matrix mul(const Matrix &f, const Matrix &s) {
        int nn = (int)f.a.size();
        int mm = (int)f.a[0].size();
        int k = (int)s.a[0].size();
        Matrix res(nn, mm);
        for (int i = 0; i < nn; i++) {
            for (int j = 0; j < k; j++) {
                int val = 0;
                for (int t = 0; t < mm; t++) {
                    val = add(val, mul(f.a[i][t], s.a[t][j]));
                }
                res.set(i, j, val);
            }
        }
        return res;
    }
};
 
Matrix binpow(Matrix f, int b) {
    int n = (int)f.a.size();
    Matrix res(n, n);
    for (int i = 0; i < n; i++) {
        res.set(i, i, 1);
    }
    while (b > 0) {
        if (b % 2 == 1) {
            res = mul(res, f);
            b--;
        } else {
            f = mul(f, f);
            b /= 2;
        }
    }
    return res;
}

int solve(int st, int ad, int len) {
	int pnt = st + ad * (len - 1);
	int p = binpow(10, lenn(pnt));
	Matrix go(3, 3);
	go.set(0, 0, p);
	go.set(0, 1, 0);
	go.set(0, 2, mul(sub(0, ad), p));
	go.set(1, 0, 1);
	go.set(1, 1, 1);
	go.set(1, 2, 0);
	go.set(2, 0, 0);
	go.set(2, 1, 0);
	go.set(2, 2, p);
	go = binpow(go, len);
	Matrix bs(3, 1);
	bs.set(0, 0, pnt);
	bs.set(1, 0, 0);
	bs.set(2, 0, 1);
	Matrix rs = mul(go, bs);
	return rs.a[1][0];
}

int mul(int a, int b, int p) {
	a %= p;
	b %= p;
	return (a * b) % p;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int l, a, b;
	cin >> l >> a >> b >> M;
	vector<pair<int, int>> sgs;
	int stlen = lenn(a);
	int enlen = lenn(a + (l - 1) * b);
	int pnt = 0;
	for (int i = stlen; ; i++) {
		if (i == enlen) {
			sgs.push_back({pnt, l - 1});
			break;
		} else {
			int en = src(lenn(a + b * pnt), l, a, b);
			sgs.push_back({pnt, en});
			pnt = en + 1;
		}
	}
	int ans = 0;
	int cm = 1;
	for (int i = (int)sgs.size() - 1; i >= 0; i--) {
		int v = solve(a + (sgs[i].first) * b, b, sgs[i].second - sgs[i].first + 1);
		v = mul(v, cm);
		ans = add(ans, v);
		int one = binpow(10, lenn(a + (sgs[i].first) * b));
		cm = mul(cm, binpow(one, (sgs[i].second - sgs[i].first + 1)));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256