In the heart of ICPC's code-filled realm, you encountered a cryptic two-dimensional character array consisting of lowercase latin letters. But, here's the twist: vowels were ignored to create a labyrinth of consonants. As you navigate through this labyrinth using the directions (left, right, up, and down) provided, you'll collect characters to create a secret message. After decoding this message, you'll face a set of thrilling word challenges.
There are two key steps to your quest:
: Your journey starts at the top-left cell , where you'll follow the given directions in sequence. During your journey, you must record the characters you collect while ignoring Vowels. Your objective is to display the string after navigating the array.
: After you've collected a sequence of characters using , you'll receive a series of word queries. Your mission is to determine if each query word can be formed using the collected characters while preserving their order. That means if you pick a character from index of the navigated string to form a query word, you can not pick a character from the lower index anymore.
First line of the test case contains four integers: and representing the array dimensions, length of the string of valid direction and the number of queries separated by spaces.
Each of the next lines contains a string of characters consist of lowercase latin letters.
The next line contains the string of valid directions for .
Finally, each of the next lines contains a query string consist of lowercase latin letters.
{}
First line of the output contains a single string formed by .
For each of the next lines, print "YES" if the query string can be formed using and "NO" otherwise without quotations.
Input | Output |
---|---|
3 3 6 2 aei ouk btc rrdldl bk kb | ktb NO YES |
Word can not be formed because, after picking character you can not pick as it is situated in lower index. Word can be formed because, first you can pick and then you can pick from higher index. |
Input | Output |
---|---|
4 4 11 3 rnst xiue aorp bzei dudrurrddlu p noise str | rxrxnstpr YES NO YES |