AT_past202306_l ビット行列

Description

You are given an $ H $ -by- $ W $ matrix $ A $ consisting of non-negative integers. You can perform the following operations any number of times (possibly zero): - Choose an integer $ i $ satisfying $ 1 \le i \le H $ and a non-negative integer $ X $ , and replace each element $ A_{i,j} $ in the $ i $ -th row of the matrix $ A $ with $ A_{i,j}\ \mathrm{XOR}\ X $ . - Choose an integer $ j $ satisfying $ 1 \le j \le W $ and a non-negative integer $ X $ , and replace each element $ A_{i,j} $ in the $ j $ -th column of the matrix $ A $ with $ A_{i,j}\ \mathrm{XOR}\ X $ . You are also given an $ H $ -by- $ W $ matrix $ B $ consisting of non-negative integers and $ -1 $ . Determine if it is possible to make $ A_{i,j}=B_{i,j} $ for all pairs of integers $ (i,j) $ such that $ B_{i,j} \neq -1 $ by performing the operations. What is $ \mathrm{XOR} $ ? The bitwise $ \mathrm{XOR} $ of non-negative integers $ A, B $ , denoted as $ A \oplus B $ , is defined as follows: - The $ 2^k $ ( $ k \geq 0 $ ) place of $ A \oplus B $ in binary notation is $ 1 $ if exactly one of the $ 2^k $ places of $ A $ and $ B $ in binary notation is $ 1 $ , and $ 0 $ otherwise. For example, $ 3 \oplus 5 = 6 $ (in binary notation: $ 011 \oplus 101 = 110 $ ). In general, the bitwise $ \mathrm{XOR} $ of $ k $ integers $ p_1, p_2, p_3, \dots, p_k $ is defined as $ (\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k) $ , and it can be proven that this does not depend on the order of $ p_1, p_2, p_3, \dots p_k $ .

Input Format

The input is given from Standard Input in the following format: > $ H $ $ W $ $ A_{1,1} $ $ A_{1,2} $ $ \dots $ $ A_{1,W} $ $ A_{2,1} $ $ A_{2,2} $ $ \dots $ $ A_{2,W} $ $ \vdots $ $ A_{H,1} $ $ A_{H,2} $ $ \dots $ $ A_{H,W} $ $ B_{1,1} $ $ B_{1,2} $ $ \dots $ $ B_{1,W} $ $ B_{2,1} $ $ B_{2,2} $ $ \dots $ $ B_{2,W} $ $ \vdots $ $ B_{H,1} $ $ B_{H,2} $ $ \dots $ $ B_{H,W} $

Output Format

If it is possible to satisfy the condition, print `Yes`; otherwise, print `No`.

Explanation/Hint

### Sample Explanation 1 Initially, $ A $ is as follows: ``` 1 2 3 4 ``` Performing the operation with $ X=1 $ on the second column, we get: ``` 1 3 3 5 ``` Performing the operation with $ X=2 $ on the second row, we get: ``` 1 3 1 7 ``` Thus, it is possible to satisfy the condition, so print `Yes`. ### Sample Explanation 2 In this case, it is impossible to satisfy the condition no matter what, so print `No`. ### Constraints - $ 1 \le H,W \le 500 $ - $ 0 \le A_{i,j} < 2^{30} $ - $ -1 \le B_{i,j} < 2^{30} $ - All input values are integers.