#abc129f. [abc129_f]Takahashi's Basics in Education and Learning
[abc129_f]Takahashi's Basics in Education and Learning
Problem Statement
There is an arithmetic progression with terms: .
The initial term is , and the common difference is . That is, holds.
Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence would be concatenated into . What is the remainder when that integer is divided by ?
Constraints
- All values in input are integers.
- All terms in the arithmetic progression are less than .
Input
Input is given from Standard Input in the following format:
Output
Print the remainder when the integer obtained by concatenating the terms is divided by .
Sample Input 1
5 3 4 10007
Sample Output 1
5563
Our arithmetic progression is , so the answer is mod , that is, .
Sample Input 2
4 8 1 1000000
Sample Output 2
891011
Sample Input 3
107 10000000000007 1000000000000007 998244353
Sample Output 3
39122908