Dr. Horrible desperately wants to get into the Evil League of Evil, but he is having a hard time proving that he is the criminal mastermind he claims to be. Bad Horse rules the League with an iron hoof and is reviewing the application with extreme skepticism. Meanwhile his arch-nemesis, Captain Hammer -- hero of the people and corporate tool -- keeps making life difficult for our poor villain. But everything is about to change: Dr. Horrible is ready to pull off a major heist. The wonderflonium he needs to finish his freeze ray is being moved by courier van -- candy from a baby. Sadly it is not that simple. The device he built to control the van has turned into a tangle of wires that must be untangled. He would ask his roommate Moist to do it, but keeping Moist away from circuitry is probably wise (for obvious reasons). So you had better do it, and do it fast.

Figure 5: Connection point labels
Your job is to determine where a wire ends, given where it starts, for a variety of circuit boards. A circuit board is a rectangular grid of squares. Each square has 8 connection points, two on each side. A square may hold any number of wires (from 0 to 4 inclusive), each joining one connection point of the square to another. Every connection point is used by at most one wire; there is no branching.
Label a square's connection points A through H (always uppercase), starting at the left connection on the top edge and moving clockwise. So A and B are the left and right connections on the top edge; C and D are the top and bottom connections on the right edge; E and F are the right and left connections on the bottom edge; and G and H are the bottom and top connections on the left edge. A square is then described by the wires it contains. For example, a square with a wire from the left connection of the top edge to the bottom connection of the right edge, a wire from the left connection of the bottom edge to the right connection of the bottom edge, and a wire from the right connection of the top edge to the top connection of the left edge is described as "AD BH EF". Each pair is written alphabetically (BH, not HB), and the pairs within a square are listed in alphabetical order.
Squares sit flush against one another to form the board. For any square, connection points A and B join F and E respectively of the square above it (and vice versa for the square below it). Connection points C and D join H and G respectively of the square to its right (and vice versa for the square to its left). Wherever a square has a wire reaching a connection point on a shared edge, the matching connection point of the neighboring square is guaranteed to continue that path. There are no broken paths: every path begins and ends at the outer edge of the board.
The input contains several puzzle sets. Each puzzle set has two parts: a board description followed by a list of starting points.
The board description begins with one line containing two integers $h$ and $w$ ($1 \le h, w \le 20$), separated by a space -- the height and width of the board, measured in squares. Then come $n$ lines ($1 \le n \le h \cdot w$) of square descriptions, in no particular order. Each such line describes one square and begins with the square's number. Squares are numbered left to right, top to bottom, starting at $1$; for example, the top-right square is numbered $w$. After the number comes the wiring of that square, in the format described above, with the number and all wire pairs separated by single spaces. Not every square is listed, and a square is described at most once per board. Any square that is not listed has no wires.
The board description is separated from the list of starting points by a line containing a single $0$. The starting points appear on the next line, each written as a number immediately followed by a letter, separated from one another by single spaces: the number is the square and the letter is the connection point to start from. Only connection points on the outside of the board are given, and only connection points that are actually used by a wire. This line is followed by one empty line before the next puzzle set.
The end of the input is marked by two zeros separated by a space ("0 0") in place of the usual first line of a puzzle set.
For each puzzle set, output one line consisting of "Board", a space, the board's number (the first puzzle set is board $1$, and the number increases by $1$ for each following puzzle set), and a colon (":").
Then, for each starting point in that set, output one line in the format "{startpoint} is connected to {endpoint}". For example, if the starting point is 1A and the wire ends at 9H, the line is "1A is connected to 9H". Capitalization matters. Wires are bidirectional, so within the same puzzle a starting point of 9H would give "9H is connected to 1A". The letters in both the start point and the end point must be uppercase. There should be no other marks or punctuation.
Separate the output of consecutive puzzle sets with a blank line.

Figure 6: First sample case