INPUT FILE: puzzle.in
OUTPUT FILE: puzzle.out
Given a 2D square word puzzle and a list of words, search for the words in
the grid.
Words and puzzle will be given in upper case.
Words can be in any of the principal 8 directions, but they must be in a straight
line.
If a word appears more than once, you only need to list one of the occurrences.
The size of the puzzle is <= 100.
INPUT
The first line contains K, the number of test cases. For each test case
there is N, the size (side length) of the square puzzle, followed by its contents
on N rows, followed by M, the number of words to search for, and finally the
M words which you have to search for.
OUTPUT
For each word output "Not found" if it is not found in the puzzle,
or "c1, r1 to c2,
r2" where c1, r1,
c2, r2 are the starting and finishing rows
respectively.
Separate test cases by blank lines.
Sample Input File
1 5 ALABA BLABL JUICE HELLO DADAD 3 ALI DOE DOLL
Output for Sample Input
1, 1 to 3, 3 5, 5 to 5, 3 Not found