Problem Statement
For non-negative integers x and k, the k-th lowest digit of x is the remainder when bigllfloorfracx10kbigrrfloor is divided by 10. For instance, the 0-th, 1-st, 2-nd, and 3-rd lowest digits of 123 are 3, 2, 1, and 0, respectively.
You are given positive integers N, M, K, and sequences of non-negative integers A=(A1,ldots,AN) and B=(B1,ldots,BN).
Consider rearranging A by the following process.
- Do the following M times.
- Choose an integer k such that 0leqkleqK−1.
- Then, perform a stable sort on A by k-th lowest digit. That is, let A(d) be the subsequence of A composed of all elements of A whose k-th lowest digits are d, and replace A with the concatenation of A(0),A(1),ldots,A(9) in this order.
There are KM ways to execute this process. How many of them end up making A equal B? Find this count modulo 998244353.
Constraints
- 1leqNleq2times105
- 1leqMleq109
- 1leqKleq18
- 0leqAi<10K
- 0leqBi<10K
- A and B are equal as multisets. That is, every integer x occurs the same number of times in A and B.
The input is given from Standard Input in the following format:
N M K
A1 ldots AN
B1 ldots BN
Output
Print the number, modulo 998244353, of ways to execute the process that end up making A equal B.
Sample Output 1
Let k1 and k2 be the k chosen in the first and second iterations, respectively. For instance, if k1=0 and k2=1, then A changes as follows.
- A stable sort by k1-th (0-th) lowest digit makes A=(42,74,54).
- A stable sort by k2-th (1-st) lowest digit makes A=(42,54,74).
Here are all the ways to execute the process and the resulting A.
- (k1,k2)=(0,0): A=(42,74,54).
- (k1,k2)=(0,1): A=(42,54,74).
- (k1,k2)=(0,2): A=(42,74,54).
- (k1,k2)=(1,0): A=(42,54,74).
- (k1,k2)=(1,1): A=(42,54,74).
- (k1,k2)=(1,2): A=(42,54,74).
- (k1,k2)=(2,0): A=(42,74,54).
- (k1,k2)=(2,1): A=(42,54,74).
- (k1,k2)=(2,2): A=(74,42,54).
Sample Output 2
There is no way to satisfy the condition.
Sample Output 3
All 4100 ways satisfy the condition.