
Ron mixed several potion ingredients in a test tube and began observing the precipitate that formed.
Write a program to determine the shape of the precipitate. The simulation is conducted on a two-dimensional grid of cells. All ingredients fall downward at the same speed, moving synchronously. A group of ingredients will move downward if nothing obstructs their movement (that is, only empty cells are beneath them). If identical ingredients are located in adjacent cells sharing a side, they become chemically bonded and can only move downward together.
The first line contains two integers separated by a space: the dimensions of the test tube (1 \leq N \leq 100) and (1 \leq M \leq 100). The next lines each contain characters, which represent the initial state. The symbol . (dot) represents an empty cell (solution). Different potion ingredients are denoted by different Latin letters (uppercase or lowercase, case-sensitive) and digits.
Output lines, each containing characters—the resulting precipitate.
Example 1