Cube Coloring#2372

Cube Coloring

3 seconds
256 megabytes
Very easy

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 extremely happy when he is at work coloring beautiful shapes.

Yesterday, an old artist came to Mr. Magnifizer and offered him a job. The artist needs a cube to be colored, which will be an important part of his next exhibition. However, he only has a single vision of how the cube should look.

A face vision is what the cube should look like when observing a certain face. It consists of the color of the face the observer is looking at (the "main" face), followed by the list of colors of the faces which have a common edge with the main face. The order of the adjacent faces is not fixed, because the vision determines the overall impression, not specific details.

The vision of the whole cube consists of the face visions of all its faces, in no particular order.

Although Mr. Magnifizer is experienced in coloring cubes and other shapes, this task seems quite difficult to him. Help him! Given the vision of the cube, find a way to color the cube to satisfy it.

Input

The single line of the input file contains six words. Each word describes the face vision of a certain face of the cube. The description consists of five English uppercase letters: the color of the main face (the first letter), and the colors of its adjacent faces. Equal letters define equal colors, and different letters define different colors.

Output

If it is impossible to color the cube according to the given vision, print "Impossible".

If there is a single way to color the cube (ways that can be transformed into one another by rotating the cube are considered the same), output the colors of the faces in a single line, from the first face to the sixth, as shown in the example. Any rotation of the cube is acceptable.

If there are several ways to color the cube, output any two of them. Each coloring should be printed on its own line.

Examples

Example 1

Loading
Loading