#K62447. Falling Stones
Falling Stones
Falling Stones
In this problem, you are given a grid of size 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 and () which represent the number of rows and columns of the grid. The following lines each contain a string of length consisting of the characters '*' (stone) and '.' (empty space).
outputFormat
Output the grid after all stones have fallen. Print lines, each line is the final state of the corresponding row in the grid.## sample
4 4
.*..
***.
....
....
....
....
.*..
***.
</p>