Crosswords |
This problem deals with crosswords, as they are known from every newspaper. A cross-word is words arranged horizontally and vertically in a rectangle. Two words can share one character where they are crossing. The problem is to decide whether the crossword is solved correctly or not.
Input file contains several test cases. Each test has any number of lines of the format:
word x y d.
word, x, y and d are
in standard text
format. x and y mean the coordinate of the starting point of
the word and d is the
direction in which the word is written. x and y are positive integers less than 100. The length the word is less than 10. Between word x y d there is exactly one space and word begins from the first column. The coordinate system starts at
the upper
left of the rectangle with the coordinates (1,1). The direction is given
by a single
character where u means upwards, r means right, d means down and l means left.
Given crossword will always be correct.
These lines are follwed by a # symbol, and then the test contains the ``solution" in the following format: The first line of the ``solution" is the minimal width (minimal right edge coordinate) of the crossword, and the second line is the minimal height (minimal bottom coordinate) of the crossword needed to make crossword. The third line is all the characters of the ``solution" (only lower case characters - a ... z) listed from left to right, from top to bottom at the end of which stands single $ symbol ($ is not a part of the ``solution" and just indicates the end of the ``solution" line). The EOF indicates the end of input file.
For each test case output must be one of the following sentences:
or
second 1 1 r vis 1 3 r file 2 4 u castle 3 1 d end 6 3 u # 6 6 second la nvis e ft l e $ sample 1 4 r output 1 7 r for 3 3 u crossword 1 1 d is 2 5 l correct 1 1 r # 7 9 correctr o o f sample si w output r d $
The solution is correct. The solution is correct.