#P7956. Meteor Fall Restoration

    ID: 21140 Type: Default 1000ms 256MiB

Meteor Fall Restoration

Meteor Fall Restoration

You are given a photograph before a meteor fall. The photograph can be represented as an R×SR\times S character matrix. The character (X) represents a part of the meteor, (#) represents the ground, and (.) represents air. All (X) characters are connected. It is guaranteed that the meteor is located strictly above the ground, i.e., there exists a row that consists only of (.) such that all (X) are above it and all (#) are below it. In addition, the last row of the photo is always composed entirely of (#).

After the meteor falls vertically, its relative shape is preserved and the ground remains unchanged. Your task is to restore the photograph after the meteor has landed. The meteor will fall until any part of it is immediately above the ground.

inputFormat

The first line contains two integers (R) and (S) (number of rows and columns). The following (R) lines each contain a string of length (S), representing the photograph.

outputFormat

Output the restored photograph after the meteor has fallen. Print (R) lines, each with (S) characters.

sample

5 6
......
..XX..
...X..
......
######
......

...... ..XX.. ...X.. ######

</p>