However, Samarth is rusty when it comes to reading. He's never been particularly good at it and always had an ICPC teammate read problems for him. So when Samarth read the one sentence problem statement in Trapping Rain Water, he did not realize that the 2D structure is an elevation map. Instead, Samarth has the following assumptions about the 2D structure:
Samarth also has the following assumptions about how water works:
Help Samarth determine which cells will trap rain water. After all, how hard can a LeetCode problem be?
The first line of input consists of two integers $$$n$$$ and $$$m$$$ $$$(3 \le n,m \le 10^6, n\cdot m \le 10^6)$$$ — the dimensions of the grid.
The following $$$n$$$ lines of input each contain a row of the grid, represented as a string of $$$m$$$ characters which are either '.' or 'x'.
It is guaranteed that the last row of the grid only has 'x'.
Output the grid after it has rained. Specifically, output $$$n$$$ lines of $$$m$$$ characters each. Each character in the grid should be 'x' (block), '.' (empty cell), or '$$$\texttt{\textasciitilde}$$$' (filled with water).
5 12...................x.......x...xx.x..x.xx.xxxxxxxxxxxxxxxxxx
............ .......x.... ...x~~~xx~x. .x~xx~xxxxxx xxxxxxxxxxxx
7 5.....x...xx...xxx.xxx.x.xx...xxxxxx
..... x~~~x x~~~x xx~xx x.x.x x...x xxxxx
8 7xxx.xxx........xx.x.....xx.........xx.x...x..x..xxxxxxxx
xxx.xxx ....... .xx~x.. ...xx.. ....... xx~x... x~~x~~x xxxxxxx
7 7xxx.xxx..............x.xxx..x.x.x.xx.....xxxxxxxx
xxx.xxx ....... ....... x.xxx.. x~x~x~x x~~~~~x xxxxxxx
5 7xxxxx.x....x..x.x.x.xx.x...xxxxxxxx
xxxxx.x ....x.. x~x~x~x x~x~~~x xxxxxxx
| Name |
|---|


