#K62447. Falling Stones

    ID: 31533 Type: Default 1000ms 256MiB

Falling Stones

Falling Stones

In this problem, you are given a grid of size n×mn \times m consisting of stones (denoted by '') and empty spaces (denoted by '.'). Each stone will fall downwards in its respective column as if influenced by gravity. That is, in each column, all stones should be moved to the bottom, while the empty spaces remain above.

For example, consider the grid below:

.
.. **. .... .... </pre> After simulating gravity, the grid becomes:
....
....
.
.. ***. </pre>
Your task is to compute the final grid after all the stones have fallen.

inputFormat

The first line contains two integers nn and mm (1n,m10001 \leq n, m \leq 1000) which represent the number of rows and columns of the grid. The following nn lines each contain a string of length mm consisting of the characters '*' (stone) and '.' (empty space).

outputFormat

Output the grid after all stones have fallen. Print nn lines, each line is the final state of the corresponding row in the grid.## sample

4 4
.*..
***.
....
....
....

.... .*.. ***.

</p>