Bart’s sister Lisa has created a new civilization on a
two-dimensional grid. At the outset each grid location may be
occupied by one of three life forms: Rocks, Scissors, or
Papers. Each day, differing life forms occupying horizontally
or vertically adjacent grid locations wage war. In each war,
Rocks always defeat Scissors, Scissors always defeat Papers,
and Papers always defeat Rocks. At the end of the day, the
victor expands its territory to include the loser’s grid
position. The loser vacates the position.
Your job is to determine the territory occupied by each life
form after $n$ days.
The first line of input contains $1 \le t \le 5$, the number of test
cases. Each test case begins with three posititve integers not
greater than $100$:
$r$ and $c$, the number of rows and columns in
the grid, and $n$, the
number of days. The grid is represented by the $r$ lines that follow, each with
$c$ characters. Each
character in the grid is ‘R’,
‘S’, or ‘P’, indicating that it is occupied by Rocks,
Scissors, or Papers respectively.
For each test case, print the grid as it appears at the end
of the $n$th day.
|Sample Input 1
||Sample Output 1
3 3 1
3 4 2