PROGRAMMING:String detection based on DFA
Deterministic finite state automata (DFA) can be understood as a structure composed of several States, which can automatically transform between states through certain rules. One of the states can only be transformed into one state, that is, certainty.
The figure below is a schematic diagram of a DFA.

The initial state is $$d_ 0 $$, and then read in the characters one by one$$ d_ 0 $$is converted to $$d when it encounters' a '_ 1$$;$$ d_ 1 $$changes to state $$d after encountering 'B'_ 2$$;$$ d_ 2 $$is still $$d after meeting 'B'_ 2$$;$$ d_ 2 $$is converted to $$d when it encounters' C '_ 3$$。$$ d_ 1 $$changes to state $$d after encountering 'C'_ 3,..., and so on.
The one with double circles represents the final state. When a string reaches the final state at the end of reading, it can pass the DFA detection.
The automaton in the figure above can be represented by the regular expression 'a (B | C) *'.
Now give a DFA, and a string, judge whether it can pass the DFA detection.
###Input format:
The first line gives the integers $$M $$and $$n $$(0 < m < = 100,0 < n < = 2000) $$, representing the number of States and transition rules of DFA respectively. The state is represented by the numbers $$0 $, $$1 $, $$2 $, $$m - 1 $, * * the initial state is 0 * *.
The second line gives the integers $$k $$and $$k $$integers $$t_ 1$$, $$t_ 2$$, …, $$t_ K$$。 Indicates that there are $$k $$final states, $$t_ 1$$ - $$t_ K $$is the number of the final state.
After that, $$n $$lines, each line gives a rule in the following format:
`Status 1 status 2 character`
The characters are upper and lower case letters (A-Z and A-Z). For example, '0 1 a' indicates that the state 0 encounters the character 'a' and changes to state 1.
Next, the integer $$q $$is given to indicate that there are $$q $$strings to be detected.
Finally, the $$q $$line gives a string for each line.
###Output format:
For each string to be detected, output 'yes' or' no 'to indicate whether it can pass the detection.
###Input example:
```in
4 7
3 1 2 3
0 1 a
1 2 b
1 3 c
2 3 c
3 2 b
3 3 c
2 2 b
four
abc
abdc
a
aab
```
###Output example:
```out
Yes
No
Yes
No
```
answer:If there is no answer, please comment
The figure below is a schematic diagram of a DFA.

The initial state is $$d_ 0 $$, and then read in the characters one by one$$ d_ 0 $$is converted to $$d when it encounters' a '_ 1$$;$$ d_ 1 $$changes to state $$d after encountering 'B'_ 2$$;$$ d_ 2 $$is still $$d after meeting 'B'_ 2$$;$$ d_ 2 $$is converted to $$d when it encounters' C '_ 3$$。$$ d_ 1 $$changes to state $$d after encountering 'C'_ 3,..., and so on.
The one with double circles represents the final state. When a string reaches the final state at the end of reading, it can pass the DFA detection.
The automaton in the figure above can be represented by the regular expression 'a (B | C) *'.
Now give a DFA, and a string, judge whether it can pass the DFA detection.
###Input format:
The first line gives the integers $$M $$and $$n $$(0 < m < = 100,0 < n < = 2000) $$, representing the number of States and transition rules of DFA respectively. The state is represented by the numbers $$0 $, $$1 $, $$2 $, $$m - 1 $, * * the initial state is 0 * *.
The second line gives the integers $$k $$and $$k $$integers $$t_ 1$$, $$t_ 2$$, …, $$t_ K$$。 Indicates that there are $$k $$final states, $$t_ 1$$ - $$t_ K $$is the number of the final state.
After that, $$n $$lines, each line gives a rule in the following format:
`Status 1 status 2 character`
The characters are upper and lower case letters (A-Z and A-Z). For example, '0 1 a' indicates that the state 0 encounters the character 'a' and changes to state 1.
Next, the integer $$q $$is given to indicate that there are $$q $$strings to be detected.
Finally, the $$q $$line gives a string for each line.
###Output format:
For each string to be detected, output 'yes' or' no 'to indicate whether it can pass the detection.
###Input example:
```in
4 7
3 1 2 3
0 1 a
1 2 b
1 3 c
2 3 c
3 2 b
3 3 c
2 2 b
four
abc
abdc
a
aab
```
###Output example:
```out
Yes
No
Yes
No
```
answer:If there is no answer, please comment