#P3585. [POI 2015 R1] 印章 Seal
[POI 2015 R1] 印章 Seal
Description
On an grid paper, some cells should be stamped black, and the remaining cells should be left white.
You have an stamp in which some cells are raised (will pick up ink). Determine whether you can use this stamp to produce the pattern on the paper, under the following rules:
- The stamp cannot be rotated.
- You cannot stamp outside the paper.
- No cell on the paper may be stamped more than once.
Input Format
The first line contains an integer (), the number of test cases.
Then for each of the test cases:
- The first line contains integers ().
- The next lines, each with characters, describe the target pattern on the paper.
.means blank,xmeans black. - The next lines, each with characters, describe the stamp.
.means not inked,xmeans inked.
Output Format
For each test case, output TAK (yes) or NIE (no).
2
3 4 4 2
xx..
.xx.
xx..
x.
.x
x.
..
2 2 2 2
xx
xx
.x
x.
TAK
NIE
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号