P5297 [Beijing NOI Qualifier Training 2019] Perfect Tower Defense.

Background

Xiao N has recently started to like playing a tower defense game.

Description

The game board is an $n \times m$ grid. Each cell may contain one of the following objects: 1. Type A turret: shoots lasers in both up and down directions at the same time, represented by `|`. 2. Type B turret: shoots lasers in both left and right directions at the same time, represented by `-`. 3. Empty cell: a laser passes through and keeps moving in the same direction, represented by `.`. 4. Obstacle: when a laser reaches it, the laser disappears, represented by `#`. 5. Main mirror: when a laser reaches it, it changes direction according to the laws of physics and continues moving, represented by `\`. 6. Secondary mirror: when a laser reaches it, it changes direction according to the laws of physics and continues moving, represented by `/`. Note that lasers can pass through each other, but if a laser goes out of the grid boundary, it also disappears. Xiao N is a perfectionist player. He wants every empty cell to be hit by at least one laser, but he must not let any laser hit his own turrets and damage them. Xiao N can change any number of Type A turrets into Type B turrets, and can also change any number of Type B turrets into Type A turrets. Can you tell whether he can achieve his goal through these modifications?

Input Format

The first line contains a positive integer $T$, the number of test cases. For each test case, the first line contains two positive integers $n, m$. The next $n$ lines each contain a string of length $m$, describing the board.

Output Format

For each test case, if there is no solution, output one line `IMPOSSIBLE`. Otherwise, output one line `POSSIBLE`, then output the modified board. If there are multiple solutions, output any one.

Explanation/Hint

### Constraints For $100\%$ of the testdata: - $1\le T \le 200$. - $1\le n,m \le 50$. Special Judge provided by @tiger2005. Translated by ChatGPT 5