Time travel is finicky business. Occasionally you end up hundreds of millions of years away from when you intended. So as a time-traveling salesman, Tim often wants to verify that he has landed near his target date. This is easy when he travels forward in time, because there are always people around he can ask. Traveling back in time is a different story: humans have not been around for very long, much less kept track of time with calendars. For trips far into the past, Tim wants a new way to confirm which era he has landed in.
One strategy is to use the principles of geologic dating. By taking a core sample of earth where he lands, Tim can study the layers of sediment, called strata, each of which formed during a specific geologic period. Telling one stratum from another is easy, but it is impossible to say which geologic period a stratum belongs to from the sediment alone, because of local variations in climate and soil. This is where fossils come in. If a stratum contains a fossil, the corresponding geologic period is known, based on fossil records and the fact that every member of a species lived during the same geologic period. So to verify when he has landed, all Tim needs to know is whether the strata in the core sample are consistent with the target time he entered into his time machine.
The first line contains the number of test cases $K$. Then follow $K$ test cases, each of the following form.
The first line of a test case contains three integers $t$, $w$, and $d$: Tim's target time (in millions of years ago), and the width and depth of the core sample, with $0 \le t \le 3000$ and $1 \le w, d \le 100$. The next $d$ lines each contain $w$ characters and describe the core sample. Each character is a digit (0–9) or a capital letter (A–M).
A digit is sediment belonging to a particular stratum. Stratum 0 is the surface of the earth and therefore matches the geologic period of Tim's target time. Stratum 1 is the layer directly below stratum 0, stratum 2 the layer below stratum 1, and so on — each deeper stratum is one geologic period older than the one above it.
A capital letter is a fossil, and its label identifies a geologic period as in the table below.
| Period | Range (millions of years ago) | Fossil label |
|---|---|---|
| Quaternary | 0 to 3 | A |
| Neogene | 4 to 23 | B |
| Paleogene | 24 to 66 | C |
| Cretaceous | 67 to 146 | D |
| Jurassic | 147 to 200 | E |
| Triassic | 201 to 251 | F |
| Permian | 252 to 299 | G |
| Carboniferous | 300 to 359 | H |
| Devonian | 360 to 416 | I |
| Silurian | 417 to 444 | J |
| Ordovician | 445 to 488 | K |
| Cambrian | 489 to 542 | L |
| Precambrian | 543 and older | M |
A fossil belongs to the stratum immediately surrounding it, counting the eight neighbouring cells including diagonals. If a fossil touches more than one kind of stratum (for example both 1 and 2), it belongs to the stratum with the numerically lowest digit. No fossil is completely surrounded by other fossils, and every core sample contains at least one fossil and at least one stratum.
For each test case, output Data Set x: on its own line, where x is the 1-based number of the test case. On the next line, output Yes if every fossil in the core sample is consistent with Tim's target time, and No otherwise. Separate consecutive test cases with a blank line.