The problem involves a rectangular grid representing a field, where each cell is either free or occupied. Imagine placing a snake of size in one of the free cells. The first player starts by extending the snake into an adjacent free cell. The second player then takes their turn, and the game continues in this manner. Players can only extend the snake into adjacent free cells, and once a cell is part of the snake, it becomes occupied. The player who cannot make a move loses the game. Your task is to determine, for each free cell on the field, whether the first player has a winning strategy if the snake starts in that cell.
The input begins with two integers, and (1 \le R, C \le 100), representing the number of rows and columns of the field, respectively. This is followed by lines, each containing characters. Each character is either '.' indicating a free cell, or '#' indicating an occupied cell.
Produce lines with characters each, representing the game field. Replace every '.' with 'W' if the starting cell is a winning position for the first player, or with 'L' if it is a losing position.
Example 1