for tc inrange(T): r, c, n = map(int, input().split()) mp = [list(input()) for _ inrange(r)] # map tmp = [[-1for _ inrange(c)] for _ inrange(r)] # temp map for d inrange(n): # days for i inrange(r): for j inrange(c): tmp[i][j] = mp[i][j] for i inrange(r): for j inrange(c): for x, y in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]: if x < 0or x >= r or y < 0or y >= c: continue if mp[x][y] == "R"and mp[i][j] == "S": tmp[i][j] = "R" if mp[x][y] == "S"and mp[i][j] == "P": tmp[i][j] = "S" if mp[x][y] == "P"and mp[i][j] == "R": tmp[i][j] = "P" for i inrange(r): # update for j inrange(c): mp[i][j] = tmp[i][j] for row in mp: print("".join(row)) if tc < T - 1: print()