#625
Silver I

Stamp Grid

시간 제한
2s
메모리 제한
1024MB
제출
3
정답
1
맞힌 사람
1
정답 비율
33.3%

문제

A stamp painting is a black and white painting on an N×NN \times N canvas, where certain cells are inked while others are blank. It can be described by an N×NN\times N array of characters (1≤N≤201\le N\le 20). The iith entry of the jjth column of the array is equal to * if the canvas contains ink at that square and . otherwise.

Bessie has a stamp painting that she would like to create, so Farmer John has lent her a single K×KK\times K (1≤K≤N1\le K\le N) stamp to do this and an empty N×NN \times N canvas. Bessie can repeatedly rotate the stamp clockwise by 90∘90^{\circ} and stamp anywhere on the grid as long as the stamp is entirely inside the grid. Formally, to stamp, Bessie chooses integers i,ji,j such that i∈[1,N−K+1]i \in [1,N-K+1] and j∈[1,N−K+1]j \in [1, N-K+1]; for each (i′,j′)(i',j') such that 1≤i′,j′≤K1 \le i', j' \le K, canvas cell (i+i′−1,j+j′−1)(i+i'-1, j+j'-1) is painted black if the stamp has ink at (i′,j′)(i', j'). Bessie can rotate the stamp at any time between stampings. Once a canvas cell is painted black, it remains black.

Farmer John is wondering whether it's possible for Bessie to create her desired stamp painting with his stamp. For each of TT (1≤T≤1001 \le T \le 100) test cases, help Farmer John answer this question.

입력

The first line of input contains TT, the number of test cases.

Each test case starts with an integer NN followed by NN lines, each containing a string of *s and .s, representing Bessie's desired stamp painting. The next line contains KK and is followed by KK lines, each containing a string of *s and .s, representing Farmer John's stamp.

Consecutive test cases are separated by newlines.

출력

For each test case, output "YES" or "NO" on separate lines.

예제 입력 1

4

2
**
*.
1
*

3
.**
.**
***
2
.*
**

3
...
.*.
...
3
.*.
...
...

3
**.
.**
..*
2
.*
*.

예제 출력 1

YES
YES
NO
YES
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출

제출 내역이 없습니다.

맞은 사람
#순위사용자언어시간메모리코드 길이
11069🥇
정준혁
Java45ms41508KB2817B
난이도 투표
Silver I2명 투표· 22일 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
#사용자문제결과언어시간메모리코드 길이제출 시간
11069
맞았습니다
Java45ms41508KB2817B2026. 10. 14. 00:24
11068
컴파일 에러
Java--2586B2026. 10. 14. 00:22
11067
런타임 에러
Java--2681B2026. 10. 14. 00:21