You are given a 2D array with rows and columns and asked to run the following procedure on it 100 times.
function(grid):
for each row in the grid going from top to bottom:
for each column in the grid going from left to right:
if the character in the given row and given column is an 'o' and the character in the same column and one row lower is a '.':
swap those two characters in the grid
Print out the grid after running the procedure 100 times.
Constraints
In the array, the only characters that will appear are o
, #
, and .
.
Input Specification
The first line contains two space-separated integers, and .
Each of the next lines contains characters describing the array from top to bottom.
Output Specification
Print the grid in exactly the same format after 100 simulations of the above procedure.
Sample Input
3 3
ooo
#..
..#
Sample Output
o..
#.o
.o#
Comments