Safe road system

Delete the fewest road characters so every remaining road is connected to at least two neighbours under the given adjacency rules.

Medium7GraphBacktrackingBrute forceNo attempts yetTime limit1sMemory limit64 MB

Problem

The road network of a city, seen from the air, looks like a grid of R×SR \times S unit squares. Each unit square is either empty or holds one unit piece of road. A unit piece of road is vertical, diagonal, horizontal, or a crossroad. The picture below shows one such road network.

Only 6 characters appear in the grid. . (a dot) is an empty unit square with no road on it. - (a minus) is a horizontal unit road, / and \ are diagonal unit roads, | (a pipe) is a vertical unit road, and + is a crossroad.

The table below says exactly which of the 8 neighbouring unit squares a car can use to enter the middle unit road, and which ones it can leave for. A square marked * is one the middle unit road can be reached from and driven to. A square marked # is one that cannot be used either way.

Written out character by character, the table is this.

  • | connects with the squares above and below it.
  • - connects with the squares to its left and right.
  • / connects with the squares to its upper right and lower left.
  • \ connects with the squares to its upper left and lower right.
  • + connects with all 8 neighbouring squares.

A safe road network has no dead end, so no unit road in it is joined to fewer than two neighbouring unit roads. Two unit roads are joined when, by the table above, a car can get from the first to the second and also from the second to the first. The network in the picture above is safe.

Ljubo is up to his old tricks. This year he built a few roads without a permit, and because of that the road network may no longer be safe. Make the network safe again while destroying as few unit roads as possible. Destroying one unit road means turning its character into . (a dot).

Input

The first line contains the number of rows RR and the number of columns SS of the road network, where 1R201 \le R \le 20 and 1S201 \le S \le 20.

Each of the next RR lines contains SS characters describing the network in the way given above. Only the 6 characters listed above appear.

Output

Print RR lines of SS characters each, the repaired road network, which must be safe. You may not change the original network in any way other than turning some unit road into . (a dot).

The safe road network with the smallest possible number of destroyed roads can be shown to be unique.