A Puzzling Problem

Time limit1sMemory limit128 MB

Problem

Anna Graham is a puzzle maker who takes pride in the quality and complexity of her work. She makes puzzles of all kinds — crosswords, logic problems, acrostics, and word searches, to name just a few. For each kind of puzzle she has developed a set of rules that she requires herself to follow.

For word search puzzles she insists not only that all the words be connected to one another (as in most word searches), but also that removing any single word from the word list will never cause one or more of the remaining words to become disconnected from the rest. As in a standard word search, each word is placed along a straight line of cells in one of the eight directions — horizontal, vertical, or diagonal, forwards or backwards — and two words are connected when their lines pass through a common cell. For example, of the two sample puzzles below, the first meets this requirement but the second does not — removing the word Pascal disconnects Java from the other words.

Your job is to write a program that checks whether Anna's word search puzzles meet her standard.

Input

The input consists of multiple test cases. The first line of each test case contains three integers $n$, $m$, and $l$, where $n$ and $m$ are the number of rows and columns of the puzzle grid and $l$ is the number of words. The next $n$ lines each contain $m$ uppercase letters (the grid), followed by $l$ lines each containing one word (the word list, in mixed case). Each word in the word list appears in the puzzle exactly once. The grid has at most 100 rows and at most 100 columns, and there are at most 100 words. The input words contain no spaces. A line with $n = m = l = 0$ marks the end of the input.

Output

For each test case, output a single line containing either Yes or No, according to whether the puzzle satisfies Anna's constraints.

Hint

Bonus Puzzle (for those of you with a little extra time).

A D N E R H E B E T W E S T M I N S T E R T H
Y E G R A V E M E U D R U P O B E R L I N D E
E C M I C H I G A N W A T E R L O O I G I N T
L G E M R C U N T D I V E L L I V R A D E C A
L E U A H R W S E I E B T T Y S N T H R E S T
A R E I I I B N V Y O R K O S A A G A L N O S
V K G M N T O A I W H F T R G G G Z A E R I T
D A R D O M U D L E I H T O N I A D E R N B H
N R S O A Y E I O D O A T N N N K U D D B I G
A O L R N N N R G R W S I T N A Q E I S E O I
R A I R C G C E H G E I P O O W I A N N G N R
G H P O G I N H H N S I N F T V N T B H E A W
M S P R T U N S O G L R D W E A O N O T S G M
U A E N F D A C L R E I R U A L D I R F L I W
G E R O L B U E I V Y L H M E L I A O N C H D
N T Y I H O O Q T N A U L D G E L H Y H T C H
I E R H E T Y M U M N A O A A Y Y A I T E I B
K W O O S T E R N E W A H S N A F G C D O M R
S U C P I A T N A B S I T M C M A S T E R N O
U G K H O W L A U R E N T I A N O T E L R A C
M A S H L A N D Y T I C E V O R G L E J P B K

 

ALMA			DAYTON			MICHIGAN		SHERIDAN
AKRON			DUQUESNE		MT VERNON NAZARENE	SLIPPERY ROCK
ALLEGHENY		EDINBORO		MUSKINGUM		SPRING ARBOR
ASHLAND 		E(astern) MICHIGAN	N(orthern) MICHIGAN	THIEL
BALDWIN-WALLACE		FANSHAWE		NOTRE DAME		TOLEDO
BEHREND			GRAND VALLEY		OBERLIN			TORONTO
BOWLING GREEN		GROVE CITY		OHIO N(orthern)		WATERLOO
BROCK			HIRAM			OHIO WESLEYAN		WESTMINSTER
CARLETON		IIT			OLIVET			WILFRID LAURIER
CEDARVILLE		INDIANA			OTTAWA			WINDSOR
CINCINNATI		LAURENTIAN		PITT			WOOSTER
C(entral) MICHIGAN	MARIETTA		PURDUE			WRIGHT STATE
CMU			MCMASTER		QUEENS			YORK
CONESTOGA		MIAMI			SAGINAW VALLEY