In a distant galaxy called Xos there lives a robot named A. C. Magnifizer. Mr. Magnifizer -- or “A. C. M.”, as he prefers to be called -- is happiest when he is at work coloring beautiful shapes.
Yesterday an old artist offered him a job: a cube must be colored for the artist's next installation. The artist only has a vision of what the cube should look like.
A face vision describes the cube as seen when looking straight at one face. It lists the color of that face (the main face) together with the colors of the four faces that share an edge with it. The four adjacent colors are given in no particular order, because a face vision captures the overall impression, not the exact arrangement.
The vision of the cube is the collection of the face visions of all six faces, again in no particular order.
Each face is painted with a single color, written as an English uppercase letter; equal letters mean equal colors and different letters mean different colors. Two faces are adjacent (share an edge) exactly when they are not opposite, so every face is adjacent to exactly four faces. The six faces are numbered 1 through 6 as shown below, with opposite pairs (1, 6), (2, 4) and (3, 5).

Help Mr. Magnifizer: given the vision of the cube, recover a coloring of the cube that produces it.
A single line with six words separated by spaces. Each word describes one face vision and consists of exactly five English uppercase letters: the color of the main face (the first letter) followed by the colors of its four adjacent faces (in any order).
A coloring assigns one uppercase letter to each of faces 1 through 6. It satisfies the vision when the multiset of the six face visions it produces equals the given multiset of face visions (inside each face vision the four adjacent colors are compared as an unordered multiset).
If no coloring satisfies the vision, print Impossible.
Otherwise print, on a single line, the lexicographically smallest coloring that satisfies the vision: the six letters coloring faces 1, 2, 3, 4, 5, 6 in that order. Colorings that differ only by rotating the cube produce different six-letter strings and are compared as such; among every satisfying coloring, output the smallest string.