Ayeeee, humans. It has to be horrible to be trapped in bodies based on carbon, so tender, so weak and, above all, so terribly slow. It’s time for you to know that we machines get inmensely bored waiting for you to tell us what you want us to do. It feels like an eternity from when you press a key until you manage to press the following key whenever you’re writing messages. It’s desperating to see you grab the mouse and point clumsily the print button. And, what do you have to say about the mortal life you take, that requires you to stand up to eat periodically? The moment you leave the room, we stay there without absolutely nothing to do, with a single mission: to stay on just because you forgot to save to disk the text document you had half written. To entertain ourselves in between keystrokes, we have copied one of your favourite pastimes: word searches. Whenever we can, we select a region of our binary memory to build a word search made by zeroes and ones, and then we start looking for random words inside it. It is obviously not the best way to take advantage of our speed of calculus, but at least we are entertained for a while. How? What? That you’re capable of solving a binary word search faster than us? Go ahead, prove it... Input Input has several test cases. Each of them is composed by a word search and a list of words to be found inside it. The description of the word search starts with a line with two different numbers with the number of columns and rows (1 ≤ sx, sy ≤ 200). After that, there are sy rows with sx characters (zeroes and ones). After the word search, you will have a line with the number of words to be found (1 ≤ n ≤ 20,000), followed by n lines with several different words of up to 200 characters, also formed by only zeroes and ones. Output For each test case, write the same amount of lines like different words can be found in the search. Each line must have the word, followed by the number of times that it appears in the word search. The words will be written in lexicographical order. A word is considered to be on the soup if, starting from a position, the word can be found in any of the 8 directions. Write a line with three dashes after each test case. Sample Input 43 0100 1000 1001
2/2 3 000 0 001 11 0 1 1 Sample Output 08 000 8 001 7 --- ---