C. Bake Sale
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The UTPC officers ordered too many Cabo Bob's burritos, and ran out of budget to buy food for the UT Open! In order to raise money, they decide to have a bake sale. But, being CS majors, none of them can cook, and they ran out of tokens to ask Claude for a recipe. They find a cookbook in the pantry, but realize that its author wrote the book for children, and thus scrambled the ingredients of every recipe in a word search. The officers have created a shopping list, but want to verify whether each ingredient is needed in the recipe so they don't overspend.

The recipe is printed as a grid of $$$r$$$ rows and $$$c$$$ columns of lowercase letters. An ingredient is hidden in the grid if you can trace its name through a sequence of cells where:

  • consecutive cells in the name share an edge (up, down, left, or right — no diagonals), and
  • no single cell is used more than once while tracing that one ingredient.

Unlike an ordinary word search, the path may bend: an ingredient can head one direction and then turn at any cell, snaking through the grid. Different ingredients are traced independently, so they may reuse the same cells.

For each ingredient on the shopping list, help the officers decide whether it is hidden in the grid.

Input

The first line contains two integers $$$r$$$ and $$$c$$$ ($$$1 \le r, c \le 10$$$) — the number of rows and columns in the grid.

Each of the next $$$r$$$ lines contains a string of exactly $$$c$$$ lowercase English letters, describing one row of the grid.

The next line contains a single integer $$$q$$$ ($$$1 \le q \le 50$$$) — the number of ingredients on the shopping list.

Each of the next $$$q$$$ lines contains one ingredient: a string of between $$$1$$$ and $$$10$$$ lowercase English letters.

Output

Print $$$q$$$ lines. On the $$$i$$$th line, print YES if the $$$i$$$th ingredient is hidden in the grid, and NO otherwise.

Examples
Input
5 5
sugar
bfyxx
ulour
txxxx
terxx
5
sugar
flour
butter
yeast
cream
Output
YES
YES
YES
NO
NO
Input
2 2
mi
kl
2
milk
oil
Output
YES
NO
Note

In the first example, sugar reads straight across the top row, while flour and butter bend as they are traced. yeast and cream cannot be formed.

In the second example, milk follows all four cells around the grid, while oil cannot be formed because there is no o.