A word search puzzle is a puzzle that involves a rectangular grid of letters and a list of words. The objective is to find and mark all those words, which are hidden inside the grid. The words may be placed horizontally, vertically, or diagonally, in either direction. When you have found a word, you mark all the letters in the grid that are involved. A letter may be part of multiple words. At the end, all the unmarked letters, from top to bottom and from left to right, form a message; this is the solution.
A certain magazine has a bunch of word search puzzles in it. They would like you to check, for each puzzle, that all words are actually in the grid. You should also be on the lookout for words that can be found in two (or more) different places – even if it does not influence the final solution. If all is well, just give the solution.
On the first line one positive number: the number of test cases, at most 100. After that per test case:
Per test case:
4 10 7 8 ELIPMOCN TACODEOL IMELBORP MGOALRRM BIPLEIEA UCATZUCE SBHEMSTT BAPC TUE TEAM PROBLEM CODE COMPILE SUBMIT CORRECT BALLOON PRIZE 2 4 3 BCB AOA PDP CEC BAPC CODE 3 4 3 BCB AOA PDP CEC BAPC CODE TEAM 2 2 10 DELEVELEDB ATESTSETPC DELEVELED TESTSET
ALGORITHMS ambiguous no solution BAPC