This will be a useful tool for you to solve block puzzles! There will be 12 test cases: 10 for basic requirements and 2 for bonus.

computer science

Description

Description

This will be a useful tool for you to solve block puzzles!
There will be 12 test cases: 10 for basic requirements and 2 for bonus.
 
You will receive several lines:
First line will have a number, which is the number of pieces. From next line, they are pairs of piece information.
First line of each pair show the "exact" width and height of the piece (No need to handle pathetic pieces!), and then following is the shape of the corresponding piece, which consist of English char, Big 'O' and minus.
After the piece information, you will get several puzzle map information. First line will also have a number, which is the number of puzzle maps. From next line, they are pairs of puzzle map information, which have the same way mentioned above to consist.
 
Bonus(Only the last two of the testing data bave these cases):
Rotating and flipping the pieces are allowed.

Input

3
4 2
OOOO
-O--
2 3
O-
OO
OO
3 3
-OO
OO-
O--
2
4 6
----
--OO 
--OO
----
O--O
O-OO
5 4
-----
O----
O--O-
OO---

 

Output

Yes

No


Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.