atcoder#ABC228G. [ABC228G] Digits on Grid
[ABC228G] Digits on Grid
Score : points
Problem Statement
There is a grid with horizontal rows and vertical columns, where each square contains a digit between and . For each pair of integers such that and , the digit written on the square at the -th row from the top and -th column from the left is .
Using this grid, Takahashi and Aoki will play together. First, Takahashi chooses a square and puts a piece on it. Then, the two will repeat the following procedures, 1. through 4., times.
- Takahashi does one of the following two actions.- Move the piece to another square that shares a row with the square the piece is on.
- Do nothing.
- Takahashi writes on a blackboard the digit written on the square the piece is on.
- Aoki does one of the following two actions.- Move the piece to another square that shares a column with the square the piece is on.
- Do nothing.
- Aoki writes on the blackboard the digit written on the square the piece is on.
After that, there will be digits written on the blackboard. Let be those digits, in the order they are written. The two boys will concatenate the digits in this order to make a -digit integer .
Find the number, modulo , of different integers that can become.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of different integers that can become.
2 2 1
31
41
5
Below is one possible scenario.
- First, Takahashi puts the piece on .
- Takahashi moves the piece from to , and then writes the digit written on .
- Aoki moves the piece from to , and then writes the digit written on .
In this case, we have . Below is another possible scenario.
- First, Takahashi puts the piece on .
- Takahashi keeps the piece on , and then writes the digit written on .
- Aoki moves the piece from to , and then writes the digit written on .
In this case, we have . Other than these, can also become , , or , but nothing else. That is, there are five integers that can become, so we print .
2 3 4
777
777
1
can only become .
10 10 300
3181534389
4347471911
4997373645
5984584273
1917179465
3644463294
1234548423
6826453721
5892467783
1211598363
685516949
Be sure to find the count modulo .