| TheForces Round #11 (DIV2.5-Forces) |
|---|
| Закончено |
You are given two $$$n*m$$$ binary matrixs $$$a,b$$$ and an integer $$$l$$$.
Define a span of length $$$l$$$ as an element set which contains $$$l$$$ elements.There are $$$2$$$ types of span:
Type $$$1$$$:$$${a_{x,y},a_{x,y+1},...,a_{x,y+l-1}}$$$
Type $$$2$$$:$$${a_{x,y},a_{x+1,y},...,a_{x+l-1,y}}$$$
Note all elements cannot exceed the boundary.
You can do the following operation for $$$a$$$ any number of times:choose a span of length $$$l$$$ in $$$a$$$,flip each number in the span.
Flip a number means:if the number is $$$0$$$ change it to $$$1$$$,otherwise change it to $$$0$$$.
Determine if $$$a$$$ can change to $$$b$$$ after any number of operations.
The first line of input will contain a single integer $$$t(t \leq 100)$$$, denoting the number of test cases.
Each test case consists of multiple lines of input.
The first line of each test case contains three space-separated integers $$$n$$$,$$$m$$$ and $$$l$$$ $$$(2 \leq n,m \leq 1000,l \leq n,m)$$$.
The next $$$n$$$ lines describe $$$a$$$.There are $$$m$$$ numbers in each line. The $$$j^{th}$$$ number in line $$$i$$$ represents $$$a_{i,j}(0 \leq a_{i,j} \leq 1)$$$.
The next $$$n$$$ lines describe $$$b$$$.There are $$$m$$$ numbers in each line. The $$$j^{th}$$$ number in line $$$i$$$ represents $$$b_{i,j}(0 \leq b_{i,j} \leq 1)$$$.
The sum of $$$n,m$$$ over all test cases won't exceed $$$1000$$$.
For each test case, output on a new line:if $$$a$$$ can change to $$$b$$$ after any number of operations,output $$$YES$$$,otherwise output $$$NO$$$.
4 2 3 2 0 1 1 1 1 1 0 1 0 0 1 1 2 3 2 0 1 1 1 0 1 1 1 1 0 0 0 4 5 3 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 4 5 4 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0 0 0
YES NO YES NO
Test case $$$1$$$:
Test case $$$2$$$:It can be proved there's no way to change $$$a$$$ to $$$b$$$.
| Название |
|---|


