After grinding through Yuhao Du Contest 7, you really liked the problem Knowledge-Oriented Problem. You believe this problem perfectly showcases the knowledge you possess, so you intend to solve a similar problem in a CTS mock contest.
Given an $M \times M$ matrix $A$ and an $N \times N$ matrix $B$, we generate a directed graph $G$ as follows:
- $G$ contains $M \times N$ vertices, where each vertex can be represented as $(i, j)$ ($1 \le i \le M, 1 \le j \le N$).
- For every $1 \le i, k \le M$ and $1 \le j \le N$, we add a directed edge from $(i, j)$ to $(k, j)$ with weight $A_{i, k}$.
- For every $1 \le i \le M$ and $1 \le j, l \le N$, we add a directed edge from $(i, j)$ to $(i, l)$ with weight $B_{j, l}$.
Clearly, we construct a directed graph of size $M \times N$. For an arborescence (directed spanning tree) of this graph, we define its weight as the product of the weights of all its edges.
Now, you want to find the sum of the weights of all arborescences rooted at $(i, j)$ for all $(i, j)$ ($1 \le i \le M, 1 \le j \le N$), modulo $998\,244\,353$.
Input
The first line contains two integers $M, N$.
The next $M$ lines each contain $M$ integers, where the $k$-th integer in the $i$-th line describes the element $A_{i, k}$.
The next $N$ lines each contain $N$ integers, where the $l$-th integer in the $j$-th line describes the element $B_{j, l}$.
Output
Output $M$ lines, each containing $N$ integers, where the $j$-th integer in the $i$-th line represents the answer for vertex $(i, j)$.
Examples
Input 1
3 4
1 8 5
3 7 4
1 2 5
1 2 3 4
5 6 7 8
2 2 3 4
5 6 7 8
Output 1
225299668 249787015 956305250 832020912
12131995 203995081 507614573 801492956
360477413 73086353 551807495 381472353
Subtasks
For all data, $1 \le M, N \le 500$, $0 \le A_{i, k}, B_{j, l} < 998\,244\,353$.
| Subtask | $M, N \le$ | Special Property | Score |
|---|---|---|---|
| $1$ | $10$ | $A, B$ are generated randomly within range | $5$ |
| $2$ | $500$ | $A_{i, k} = B_{j, l} = 1$ | $6$ |
| $3$ | $60$ | $A, B$ are generated randomly within range | $34$ |
| $4$ | $150$ | $25$ | |
| $5$ | $500$ | None | $30$ |