Hide

Problem A
Aligning Bottles

Languages da en is
/problems/aligningbottles/file/statement/en/img-0001.jpg
Sample 1.

It was a great evening. However, your friends helped themselves to bottles from the crate of Harboe pilsner without any attention to aesthetics, leaving an unorderly mess of holes and disconnected clusters. Before you go to bed, you want to restore some semblance of order.

A crate is orderly if the bottles form a single cluster of neighbouring bottles. Two bottles are neighbours in the crate if they share a divider in any of the four directions (up, down, left, right). Move as few bottles as possible to make the crate orderly.

The crate of Harboe has dimensions $4\times 6$.

Input

Four lines, each containing six characters “.” or “o”, describing a crate. The symbols mean “empty” and “bottle”, respectively. The crate contains at least $1$ bottle and is not orderly.

Output

An orderly crate in the same format as the input. It must have the same number of bottles, and the number of moved bottles must be as small as possible.

Sample Input 1 Sample Output 1
ooo..o
.o...o
o...o.
o..ooo
.oo...
.o....
ooo.o.
o.oooo
Sample Input 2 Sample Output 2
o.....
......
......
.....o
......
......
.....o
.....o
Sample Input 3 Sample Output 3
.o.o.o
o..o.o
..o...
oo..oo
......
...ooo
..o.o.
oooooo