There is a grid with $n$ rows and $m$ columns, containing a total of $(n+1) \times (m+1)$ grid points. The grid point at row $x$ and column $y$ is denoted by the pair $(x, y)$ (where both rows and columns are 0-indexed).
Initially, the grid has no edges. Now, $(3m+1)n$ directed edges are added sequentially:
- For $0 \leq i \leq n-1, 0 \leq j \leq m-1$, add $A_j$ distinct directed edges from $(i, j)$ to $(i+1, j+1)$.
- For $0 \leq i \leq n-1, 0 \leq j \leq m$, add $B_i + C_j$ distinct directed edges from $(i, j)$ to $(i+1, j)$.
- For $0 \leq i \leq n-1, 1 \leq j \leq m$, add $D_j$ distinct directed edges from $(i, j)$ to $(i+1, j-1)$.
Let $W(x, y)$ denote the number of distinct paths from $(0, 0)$ to $(x, y)$ for integers $x, y$ satisfying $0 \leq x \leq n, 0 \leq y \leq m$. It is easy to prove that the number of paths is finite. You are required to calculate the result of $\sum_{i=0}^{n}\sum_{j=0}^{m}W(i,j)E_{i}F_{j} \bmod p$.
Input
The first line contains four positive integers $c, n, m, p$. The first number represents the subtask ID (specifically, the $c$ in the sample indicates that the constraints satisfied by that sample are the same as those satisfied by the $c$-th subtask). The second and third numbers describe the size of the grid, and the fourth number represents the modulus for the answer.
The second line contains $m$ numbers, where the $i$-th number represents the value of $A_{i-1}$.
The third line contains $n$ numbers, where the $i$-th number represents the value of $B_{i-1}$.
The fourth line contains $m+1$ numbers, where the $i$-th number represents the value of $C_{i-1}$.
The fifth line contains $m$ numbers, where the $i$-th number represents the value of $D_i$.
The sixth line contains $n+1$ numbers, where the $i$-th number represents the value of $E_{i-1}$.
The last line contains $m+1$ numbers, where the $i$-th number represents the value of $F_{i-1}$.
Output
Output a single integer representing the result of $\sum_{i=0}^{n}\sum_{j=0}^{m}W(i,j)E_{i}F_{j} \bmod p$.
Examples
Input 1
1 3 3 998244353 3 1 2 3 2 2 3 2 3 1 1 3 2 1 2 1 1 1 1 1 1
Output 1
559
Note 1
$W(0,0)=1,W(1,0)=6,W(1,1)=3,W(2,0)=33,W(2,1)=30,W(2,2)=3,W(3,0)=195,W(3,1)=228,W(3,2)=45,W(3,3)=6$, and $W$ is 0 at all other positions. It is easy to obtain that the answer is 559.
Input 2
1 10 8 998244353 1 1 223419641 557071951 121 92666830 0 49321567 813349214 695956508 278 0 231694534 0 0 295169358 669776412 451 139 0 448 354283551 0 293318815 525972283 769691152 124 389028745 248 122590563 0 99 618248111 561941070 0 575275733 93848250 0 390 437 0 694493030 90 0 222 0 142 0 802726546 415295998 155953578 814571694 373754122 127 0
Output 2
460779351
Note 2
After calculation, the answer is 460779351. Note that the result must be taken modulo 998244353.
Examples 3~12
For the provided sample $i$, it satisfies all constraints of subtask $i-2$.
Subtasks
For all data, it is guaranteed that $1 \leq n, m \leq 2\times 10^5, 1 \leq p \leq 10^9$, and $0 \leq A_i, B_i, C_i, D_i, E_i, F_i < p$. It is not guaranteed that $p$ is a prime number, but for data where $p \neq 998244353$, it is guaranteed that $1 \leq n, m \leq 10^5$.
| Subtask ID | Score | $n \leq$ | $m \leq$ | $A_i$ | $B_i$ | $C_i$ | $D_i$ | $E_i$ | $F_i$ | $p=998244353$ |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 3 | $5\,000$ | $5\,000$ | Yes | ||||||
| 2 | 5 | $2 \times 10^5$ | $2 \times 10^5$ | $=0$ | $=1$ | $=0$ | ||||
| 3 | 8 | $=0$ | ||||||||
| 4 | 8 | $=0$ | ||||||||
| 5 | 5 | |||||||||
| 6 | 15 | $=[i=m]$ | ||||||||
| 7 | 16 | $20\,000$ | ||||||||
| 8 | 16 | $2 \times 10^5$ | Has exactly one non-zero position | |||||||
| 9 | 9 | |||||||||
| 10 | 15 | $10^5$ | $10^5$ | No |