QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#10520. Matrix Division

統計

For an $n \times m$ binary matrix $A$ and an $m \times p$ binary matrix $B$, their product is defined as an $n \times p$ binary matrix $C$, where $C_{i,j} = \bigoplus_{k=1}^{m} A_{i,k} \& B_{k,j}$ $^\dagger$.

Now, Link wants to perform the inverse operation of multiplication—division. Given an $n \times m$ binary matrix $A$ and an $n \times p$ binary matrix $C$, you need to find an $m \times p$ matrix $B$ such that the product of $A$ and $B$ is exactly equal to $C$.

$^\dagger$ $\oplus$ denotes the bitwise XOR operation, and $\&$ denotes the bitwise AND operation. For example: $(0011)_2 \oplus (0101)_2 = (0110)_2$, $(0011)_2 \& (0101)_2 = (0001)_2$.

Input

Each test file contains only one test case.

The first line contains three integers $n, m, p$ ($1 \le n, m, p \le 1000$).

The next $n$ lines, the $i$-th line contains $m$ integers $A_{i,1}, A_{i,2}, \dots, A_{i,m}$ ($A_{i,j} \in \{0, 1\}$), representing the elements of matrix $A$.

The next $n$ lines, the $i$-th line contains $p$ integers $C_{i,1}, C_{i,2}, \dots, C_{i,p}$ ($C_{i,j} \in \{0, 1\}$), representing the elements of matrix $C$.

Output

If no matrix $B$ satisfies the condition, output "No".

If there exists a matrix $B$ that satisfies the condition, output "Yes" on the first line, followed by $m$ lines, each containing $p$ integers $B_{i,1}, B_{i,2}, \dots, B_{i,p}$ ($B_{i,j} \in \{0, 1\}$), representing the matrix $B$ you found.

If there are multiple matrices $B$ that satisfy the condition, you may output any one of them.

Examples

Input 1

3 2 3
1 0
1 1
1 0
0 0 0
0 1 0
0 0 0

Output 1

Yes
0 0 0
0 1 0

Input 2

3 2 3
1 0
1 1
1 0
1 0 0
0 1 0
0 0 1

Output 2

No

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.