题目描述
Problem Description
There is a grid $ S $ with $ H $ rows and $ W $ columns. The cell at the $ i $-th row and $ j $-th column is referred to as cell $(i,\ j)$.
Some cells may contain obstacles. If $S_{i,\ j}$ is #, there is an obstacle in cell $(i,\ j)$. If it is ., there is no obstacle.
You also have a stamp. The bottom surface of this stamp is composed of some cells in a grid $ T $ with $ H $ rows and $ W $ columns.
Specifically, the bottom surface of the stamp is shaped by extracting only the cells $(i,\ j)$ where $T_{i,\ j}$ is #.
Here, the cells that form the bottom surface of the stamp are connected. That is, if we call the cells where $T_{i,\ j}$ is # "valid cells", any two valid cells can be reached from one to the other by repeatedly moving to adjacent cells that share an edge, passing only through valid cells.
The stamp can be moved and rotated. Determine if it is possible to overlay the bottom surface of the stamp on the grid $ S $ satisfying the following conditions:
- The edges of the cells forming the bottom surface of the stamp are all parallel to the edges of the cells in the grid $ S $.
- The bottom surface of the stamp does not extend beyond the grid $ S $.
- The bottom surface of the stamp does not overlap with any cells containing obstacles.
Input Format
The input is given from the standard input in the following format:
$ H $ $ W $ $S_{1,\ 1}S_{1,\ 2}S_{1,\ 3}\dots\ S_{1,\ W}$ $S_{2,\ 1}S_{2,\ 2}S_{2,\ 3}\dots\ S_{2,\ W}$ $S_{3,\ 1}S_{3,\ 2}S_{3,\ 3}\dots\ S_{3,\ W}$ $\hspace{40pt}\ \vdots$ $S_{H,\ 1}S_{H,\ 2}S_{H,\ 3}\dots\ S_{H,\ W}$ $T_{1,\ 1}T_{1,\ 2}T_{1,\ 3}\dots\ T_{1,\ W}$ $T_{2,\ 1}T_{2,\ 2}T_{2,\ 3}\dots\ T_{2,\ W}$ $T_{3,\ 1}T_{3,\ 2}T_{3,\ 3}\dots\ T_{3,\ W}$ $\hspace{40pt}\ \vdots$ $T_{H,\ 1}T_{H,\ 2}T_{H,\ 3}\dots\ T_{H,\ W}$
Output Format
Output Yes if it is possible to overlay the stamp satisfying the conditions in the problem statement, otherwise output No.
Sample Input and Output
Sample Input #1
3 3
...
.#.
..#
#.#
###
...
Sample Output #1
Yes
Sample Input #2
3 3
...
#..
#.#
.#.
.##
##.
Sample Output #2
No
Sample Input #3
2 5
.....
..#..
..##.
.###.
Sample Output #3
Yes
Notes/Hints
Constraints
- $1\ \le\ H\ \le\ 10$
- $1\ \le\ W\ \le\ 10$
- $S_{i,\ j}$ is either
#or.. - $T_{i,\ j}$ is either
#or.. - The cells where $T_{i,\ j}$ is
#are connected. - There exists at least one $i,\ j$ such that $S_{i,\ j}$ is
.. - There exists at least one $i,\ j$ such that $T_{i,\ j}$ is
#.
Sample Explanation 1
By rotating the stamp, it can be overlaid as shown in the figure below. The green parts represent the bottom surface of the stamp, and the gray parts represent cells with obstacles. 
Sample Explanation 2
No matter how you rotate or move the stamp, it is impossible to overlay it satisfying the conditions.
Sample Explanation 3
It can be overlaid as shown in the figure below. 
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分