#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 10005;
const int mod = 1e9 + 7;

struct disj{
	int pa[MAXN];
	void init(int n){
		iota(pa, pa + n + 1, 0);
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p; return 1;
	}
}disj;

int K;
pi a[MAXN][2];
int chk[MAXN][2];
pi par[MAXN][2];
namespace graph{
	vector<pi> gph[10005];
	int par[10005], pae[10005];
	void dfs(int x, int p){
		for(auto &i : gph[x]){
			if(i.second != p){
				par[i.second] = x;
				pae[i.second] = i.first;
				dfs(i.second, x);
			}
		}
	}

	void clear(){
		for(int i=0; i<K; i++){
			for(int j=0; j<2; j++){
				gph[a[i][j].first].clear();
				gph[a[i][j].second].clear();
				par[a[i][j].first] = -1;
				par[a[i][j].second] = -1;
			}
		}
	}

	vector<pi> inCycle(pi x){
		for(int i=0; i<K; i++){
			for(int j=0; j<2; j++){
				if(chk[i][j]){
					int w = i * 2 + j;
					int l = a[i][j].first;
					int r = a[i][j].second;
					gph[l].emplace_back(w, r);
					gph[r].emplace_back(w, l);
				}
			}
		}
		dfs(x.first, -1);
		if(par[x.second] == -1){
			clear();
			return vector<pi>();
		}
		vector<pi> ret;
		for(int y = x.second; y != x.first; y = par[y]){
			ret.emplace_back(pae[y] / 2, pae[y] % 2);
		}
		clear();
		return ret;
	}
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n, m;
char str[105][105];
int vis[105][105];

bool ok(int x, int y){ return 0 <= x && x < n && 0 <= y && y < m; }

void dfs(int x, int y, int c){
	vis[x][y] = c;
	for(int i=0; i<4; i++){
		if(ok(x + dx[i], y + dy[i]) && 
			!vis[x + dx[i]][y + dy[i]] && 
			str[x][y] == str[x + dx[i]][y + dy[i]]){
			dfs(x + dx[i], y + dy[i], c);
		}
	}
}

char dap[105][105];

int main(){
	int tc;
	scanf("%d",&tc);
	memset(graph::par, -1, sizeof(graph::par));
	for(int i=1; i<=tc; i++){
		memset(vis, 0, sizeof(vis));
		memset(chk, 0, sizeof(chk));
		memset(dap, 0, sizeof(dap));
		int cnt = 0;
		scanf("%d %d",&n,&m);
		for(int i=0; i<n; i++) scanf("%s", str[i]);
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				if(!vis[i][j]){
					++cnt;
					dfs(i, j, cnt);
				}
			}
		}
		if(cnt == 1){
			printf("Case #%d: POSSIBLE\n", i);
			for(int i=0; i<n-1; i++){
				for(int j=0; j<m-1; j++) putchar('/');
				puts("");
			}
			continue;
		}
		int answ = 0;
		disj.init(n * m);
		for(int i=1; i<n; i++){
			for(int j=1; j<m; j++){
				if(str[i-1][j-1] == str[i][j] && str[i-1][j] == str[i][j-1]){
					continue;
				}
				if(str[i-1][j-1] != str[i][j] && str[i-1][j] != str[i][j-1]){
					dap[i-1][j-1] = '.';
				}
				else if(str[i-1][j-1] != str[i][j]){
					dap[i-1][j-1] = '/';
					answ += disj.uni(vis[i-1][j], vis[i][j-1]);
					
				}
				else{
					dap[i-1][j-1] = '\\';
					answ += disj.uni(vis[i-1][j-1], vis[i][j]);
				}
			}
		}
		K = 0;
		for(int i=1; i<n; i++){
			for(int j=1; j<m; j++){
				if(dap[i-1][j-1]) continue;
				int s1 = disj.find(vis[i-1][j-1]);
				int e1 = disj.find(vis[i][j]);
				int s2 = disj.find(vis[i-1][j]);
				int e2 = disj.find(vis[i][j-1]);
				a[K][0] = pi(s1, e1);
				a[K][1] = pi(s2, e2);
				K++;
			}
		}
		for(int i=0; i<K; i++){
			bool vis[MAXN][2] = {};
			queue<pi> que;
			for(int j=0; j<2; j++){
				que.emplace(i, j);
				vis[i][j] = 1;
				par[i][j] = pi(-1, -1);
			}
			while(!que.empty()){
				auto x = que.front();
				que.pop();
				if(chk[x.first][x.second] == 0){
					auto edg = a[x.first][x.second];
					if(edg.first == edg.second) continue;
					auto adj = graph::inCycle(edg);
					if(adj.empty()){
						for(pi i = x; i != pi(-1, -1); i = par[i.first][i.second]){
							chk[i.first][i.second] ^= 1;
						}
						answ++;
						break;
					}
					else{
						for(auto &y : adj){
							if(!vis[y.first][y.second]){
								vis[y.first][y.second] = 1;
								par[y.first][y.second] = x;
								que.push(y);
							}
						}
					}
				}
				else{
					if(!vis[x.first][x.second^1]){
						vis[x.first][x.second^1] = 1;
						par[x.first][x.second^1] = x;
						que.emplace(x.first, x.second ^ 1);
					}
				}
			}
		}
		if(answ + 2 < cnt){
			printf("Case #%d: IMPOSSIBLE\n", i);
			continue;
		}
		else{
			printf("Case #%d: POSSIBLE\n", i);
			int L = 0;
			for(int i=1; i<n; i++){
				for(int j=1; j<m; j++){
					if(dap[i-1][j-1]) continue;
					if(chk[L][0]){
						dap[i-1][j-1] = '\\';
					}
					else if(chk[L][1]){
						dap[i-1][j-1] = '/';
					}
					else{
						dap[i-1][j-1] = '.';
					}
					L++;
				}
				puts(dap[i-1]);
			}
		}
	}
}

