#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int r, c, k;
char mat[100][100], ans[100][100];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int vis[100][100];
vector<char> ord;

bool valid(int i, int j) {
	return i >= 0 && i < r && j >= 0 && j < c;
}

void bfs(int i, int j, int at, int needs) {
	queue<pair<int, int>> q;
	q.push({i, j});
	vis[i][j] = 1;
	ans[i][j] = ord[at];
	if(mat[i][j] == 'R') needs--;
	while(!q.empty()) {
		auto now = q.front();
		q.pop();
		int x = now.first, y = now.second;
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if(valid(nx, ny) && !vis[nx][ny]) {
				q.push({nx, ny});
				vis[nx][ny] = 1;
				ans[nx][ny] = ord[at];
				if(mat[nx][ny] == 'R') needs--;
				if(needs == 0) return;
			}
		}
	}
}

void bfs2(int i, int j, char c) {
	queue<pair<int, int>> q;
	q.push({i, j});
	while(!q.empty()) {
		auto now = q.front();
		q.pop();
		int x = now.first, y = now.second;
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if(valid(nx, ny) && ans[nx][ny] == '-') {
				ans[nx][ny] = c;
				q.push({nx, ny});
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	for(int c = '0'; c <= '9'; c++)
		ord.push_back(c);
	for(int c = 'a'; c <= 'z'; c++)
		ord.push_back(c);
	for(int c = 'A'; c <= 'Z'; c++)
		ord.push_back(c);
	assert(ord.size() == 62);
	int t;
	cin >> t;
	while(t--) {
		cin >> r >> c >> k;
		int cnt = 0;
		for(int i = 0; i < r; i++)
			for(int j = 0; j < c; j++) {
				vis[i][j] = 0;
				ans[i][j] = '-';
				cin >> mat[i][j];
				cnt += mat[i][j] == 'R';
			}
		int get = cnt/k, at = 0;
		for(int i = 0; i < r; i++)
			for(int j = 0; j < c; j++) {
				if(at == k || mat[i][j] != 'R') continue;
				if(!vis[i][j]) {
					if(at < cnt%k) {
						bfs(i, j, at, get+1);
						at++;
					}
					else {
						bfs(i, j, at, get);
						at++;
					}
				}
			}

		for(int i = 0; i < r; i++)
			for(int j = 0; j < c; j++) {
				if(ans[i][j] != '-') {
					bfs2(i, j, ans[i][j]);
				}
			}

		for(int i = 0; i < r; i++)
			for(int j = 0; j < c; j++) {
				if(ans[i][j] == '-') {
					if(i) ans[i][j] = ans[i-1][j];
					else if(j) ans[i][j] = ans[i][j-1];
				}
				cout << ans[i][j];
				if(j == c-1) cout << endl;
			}
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <random>
#include <ctime>
using namespace std;
#define CLR(a) memset(a, 0, sizeof a)
#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
#define _all(v) (v).begin(),(v).end()
#define _endl putchar('\n')
#define _space putchar(' ')
const int32_t Accepted = 0;
template<typename T>void in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }
template<typename T, typename... Types>void in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }
template<typename T>T _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }
template<typename T>T _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }
template<typename T>void out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }
template<typename T>void print(T x) { out(x); _endl; }
template<typename T, typename... types >void print(T x, types... oth) { out(x); _space; print(oth...); }
typedef long long ll;
const int32_t MAXN = 1e6 + 5;
//------------------------Azir----------------------------

char MAP[110][110];
char ans[110][110];
char name[300];
int32_t main()
{
	//freopen("1.in", "r", stdin);
	for (int i = 0; i < 26; i++)name[i] = 'a' + i;
	for (int i = 0; i < 26; i++)name[i + 26] = 'A' + i;
	for (int i = 0; i <= 9; i++)name[i + 52] = i + '0';
	int t;
	in(t);
	while (t--)
	{
		int C = 0;
		int n, m, k;
		in(n, m, k);
		for (int i = 0; i < n; i++)
		{
			scanf("%s", MAP[i]);
			for (int j = 0; j < m; j++)
			{
				if (MAP[i][j] == 'R')C++;
			}
		}
		int x = C / k;
		int y = C % k;
		int now_id = 0;
		int now_cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//putchar(name[now_id]);
				ans[i][j] = name[now_id];
				if (MAP[i][j] == 'R')now_cnt++;
				if (y)
				{
					if (now_cnt == x + 1)
					{
						now_id++;
						now_cnt = 0;
						y--;
					}
				}
				else
				{
					if (now_cnt == x)
					{
						now_id++;
						now_cnt = 0;
					}
				}
			}
			//_endl;
		}

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				int Azir = i & 1 ? j : m - j-1;
				putchar(ans[i][Azir]);
			}_endl;
		}
	}

	return Accepted;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <random>
#include <ctime>
using namespace std;
#define CLR(a) memset(a, 0, sizeof a)
#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
#define _all(v) (v).begin(),(v).end()
#define _endl putchar('\n')
#define _space putchar(' ')
const int32_t Accepted = 0;
template<typename T>void in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }
template<typename T, typename... Types>void in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }
template<typename T>T _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }
template<typename T>T _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }
template<typename T>void out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }
template<typename T>void print(T x) { out(x); _endl; }
template<typename T, typename... types >void print(T x, types... oth) { out(x); _space; print(oth...); }
typedef long long ll;
const int32_t MAXN = 1e6 + 5;
//------------------------Azir----------------------------

char MAP[110][110];
char ans[110][110];
char name[300];
int32_t main()
{
	//freopen("1.in", "r", stdin);
	for (int i = 0; i < 26; i++)name[i] = 'a' + i;
	for (int i = 0; i < 26; i++)name[i + 26] = 'A' + i;
	for (int i = 0; i <= 9; i++)name[i + 52] = i + '0';
	int t;
	in(t);
	while (t--)
	{
		int C = 0;
		int n, m, k;
		in(n, m, k);
		for (int i = 0; i < n; i++)
		{
			scanf("%s", MAP[i]);
			for (int j = 0; j < m; j++)
			{
				if (MAP[i][j] == 'R')C++;
			}
		}
		int x = C / k;
		int y = C % k;
		int now_id = 0;
		int now_cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//putchar(name[now_id]);
				int Azir = i & 1 ? m - j - 1 : j;
				ans[i][Azir] = name[now_id];
				if (MAP[i][Azir] == 'R')now_cnt++;
				if (y)
				{
					if (now_cnt == x + 1)
					{
						now_id++;
						now_cnt = 0;
						y--;
					}
				}
				else
				{
					if (now_cnt == x)
					{
						now_id++;
						now_cnt = 0;
					}
				}
			}
			//_endl;
		}

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//int Azir = i & 1 ? m-j-1 : j;
				putchar(ans[i][j]);
			}_endl;
		}
	}

	return Accepted;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <random>
#include <ctime>
using namespace std;
#define CLR(a) memset(a, 0, sizeof a)
#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
#define _all(v) (v).begin(),(v).end()
#define _endl putchar('\n')
#define _space putchar(' ')
const int32_t Accepted = 0;
template<typename T>void in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }
template<typename T, typename... Types>void in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }
template<typename T>T _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }
template<typename T>T _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }
template<typename T>void out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }
template<typename T>void print(T x) { out(x); _endl; }
template<typename T, typename... types >void print(T x, types... oth) { out(x); _space; print(oth...); }
typedef long long ll;
const int32_t MAXN = 1e6 + 5;
//------------------------Azir----------------------------

char MAP[110][110];
char ans[110][110];
char name[300];
int32_t main()
{
	//freopen("1.in", "r", stdin);
	for (int i = 0; i < 26; i++)name[i] = 'a' + i;
	for (int i = 0; i < 26; i++)name[i + 26] = 'A' + i;
	for (int i = 0; i <= 9; i++)name[i + 52] = i + '0';
	int t;
	in(t);
	while (t--)
	{
		int C = 0;
		int n, m, k;
		in(n, m, k);
		for (int i = 0; i < n; i++)
		{
			scanf("%s", MAP[i]);
			for (int j = 0; j < m; j++)
			{
				if (MAP[i][j] == 'R')C++;
			}
		}
		int x = C / k;
		int y = C % k;
		int now_id = 0;
		int now_cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//putchar(name[now_id]);
				int Azir = i & 1 ? m - j - 1 : j;
				ans[i][Azir] = name[min(now_id,k-1)];
				if (MAP[i][Azir] == 'R')now_cnt++;
				if (y)
				{
					if (now_cnt == x + 1)
					{
						now_id++;
						now_cnt = 0;
						y--;
					}
				}
				else
				{
					if (now_cnt == x)
					{
						now_id++;
						now_cnt = 0;
					}
				}
			}
			//_endl;
		}

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//int Azir = i & 1 ? m-j-1 : j;
				putchar(ans[i][j]);
			}_endl;
		}
	}

	return Accepted;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <random>
#include <ctime>
using namespace std;
#define CLR(a) memset(a, 0, sizeof a)
#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
#define _all(v) (v).begin(),(v).end()
#define _endl putchar('\n')
#define _space putchar(' ')
const int32_t Accepted = 0;
template<typename T>void in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }
template<typename T, typename... Types>void in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }
template<typename T>T _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }
template<typename T>T _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }
template<typename T>void out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }
template<typename T>void print(T x) { out(x); _endl; }
template<typename T, typename... types >void print(T x, types... oth) { out(x); _space; print(oth...); }
typedef long long ll;
const int32_t MAXN = 1e6 + 5;
//------------------------Azir----------------------------

char MAP[110][110];

char name[300];
int32_t main()
{
	//freopen("1.in", "r", stdin);
	for (int i = 0; i < 26; i++)name[i] = 'a' + i;
	for (int i = 0; i < 26; i++)name[i+26] = 'A' + i;
	for (int i = 0; i < 9; i++)name[i + 52] = i + '0';
	int t;
	in(t);
	while (t--)
	{
		int C = 0;
		int n, m, k;
		in(n, m, k);
		for (int i = 0; i < n; i++)
		{
			scanf("%s", MAP[i]);
			for (int j = 0; j < m; j++)
			{
				if (MAP[i][j] == 'R')C++;
			}
		}
		int x = C / k;
		int y = C % k;
		int now_id = 0;
		int now_cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//out(name[now_id]);
				putchar(name[now_id]);
				if(MAP[i][j]=='R')now_cnt++;
				if (y)
				{
					if (now_cnt == x + 1)
					{
						now_id++;
						now_cnt = 0;
						y--;
					}
				}
				else
				{
					if (now_cnt == x )
					{
						now_id++;
						now_cnt = 0;
					}
				}
			}
			_endl;
		}

	}

	return Accepted;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <unordered_map>
#include <random>
#include <ctime>
using namespace std;
#define CLR(a) memset(a, 0, sizeof a)
#define _unique(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());
#define _all(v) (v).begin(),(v).end()
#define _endl putchar('\n')
#define _space putchar(' ')
const int32_t Accepted = 0;
template<typename T>void in(T& x) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; }
template<typename T, typename... Types>void in(T& x, Types& ... oth) { static char ch; static bool neg; for (ch = neg = 0; ch < '0' || '9' < ch; neg |= ch == '-', ch = getchar()); for (x = 0; '0' <= ch && ch <= '9'; (x *= 10) += ch - '0', ch = getchar()); x = neg ? -x : x; in(oth...); }
template<typename T>T _pow_mod(T a, T b, T mod) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base) % mod; base = (base * base) % mod; b >>= 1; }return res; }
template<typename T>T _pow(T a, T b) { T base = a, res = 1; while (b) { if (b & 1)res = (res * base); base = (base * base); b >>= 1; }return res; }
template<typename T>void out(T x) { char s[65]; int32_t cnt = 0; if (x > 0)while (x > 0)s[cnt++] = (x - (x / 10 * 10)) + '0', x /= 10; else if (x < 0) { while (x < 0)s[cnt++] = (x / 10 * 10) - x + '0', x /= 10; s[cnt++] = '-'; }if (cnt == 0)putchar('0'); else for (int32_t i = cnt - 1; ~i; i--)putchar(s[i]); }
template<typename T>void print(T x) { out(x); _endl; }
template<typename T, typename... types >void print(T x, types... oth) { out(x); _space; print(oth...); }
typedef long long ll;
const int32_t MAXN = 1e6 + 5;
//------------------------Azir----------------------------

char MAP[110][110];

char name[300];
int32_t main()
{
	//freopen("1.in", "r", stdin);
	for (int i = 0; i < 26; i++)name[i] = 'a' + i;
	for (int i = 0; i < 26; i++)name[i+26] = 'A' + i;
	for (int i = 0; i <= 9; i++)name[i + 52] = i + '0';
	int t;
	in(t);
	while (t--)
	{
		int C = 0;
		int n, m, k;
		in(n, m, k);
		for (int i = 0; i < n; i++)
		{
			scanf("%s", MAP[i]);
			for (int j = 0; j < m; j++)
			{
				if (MAP[i][j] == 'R')C++;
			}
		}
		int x = C / k;
		int y = C % k;
		int now_id = 0;
		int now_cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				//out(name[now_id]);
				putchar(name[now_id]);
				if(MAP[i][j]=='R')now_cnt++;
				if (y)
				{
					if (now_cnt == x + 1)
					{
						now_id++;
						now_cnt = 0;
						y--;
					}
				}
				else
				{
					if (now_cnt == x )
					{
						now_id++;
						now_cnt = 0;
					}
				}
			}
			_endl;
		}

	}

	return Accepted;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        int c = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and curr+1 < k ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j >= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and curr+1 < k ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) cont ++;
                    mat[i][j] = let[curr];
                    if( cont == each ){
                        curr ++;
                        cont = 0;
                        if( curr == cont%k ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j >= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) cont ++;
                    mat[i][j] = let[curr];
                    if( cont == each ){
                        curr ++;
                        cont = 0;
                        if( curr == cont%k ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        int c = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and c < cont ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j >= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and c < cont ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        int c = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j >= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        int c = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and curr < k ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j >= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) c ++;
                    mat[i][j] = let[curr];
                    if( c == each and curr < k ){
                        curr ++;
                        c = 0;
                        if( curr == (cont%k) ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
                mat[i][j] = let[curr];
                if( cont == each ){
                    curr ++;
                    cont = 0;
                    if( curr == cont%k ) each --;
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

#define pii pair<ll,ll>
#define ff first
#define ss second
#define pb push_back

int t, n, m, k;
string mat [105];

string let = "";
int curr = 0;

int main(){

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio();
    cin.tie(0);

    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'A' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 26 ; i ++ ){
        char c = 'a' + i;
        let.pb( c );
    }
    for( int i = 0 ; i < 10 ; i ++ ){
        char c = '0' + i;
        let.pb( c );
    }

    cin >> t ;
    while( t -- ){
        curr = 0;
        cin >> n >> m >> k;
        int cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> mat[i] ;
            for( int j = 0 ; j < m ; j ++ ){
                if( mat[i][j] == 'R' ) cont ++;
            }
        }

        int each = (cont+k-1)/k;
        cont = 0;
        for( int i = 0 ; i < n ; i ++ ){
            if( i % 2 == 0 ){
                for( int j = 0 ; j < m ; j ++ ){
                    if( mat[i][j] == 'R' ) cont ++;
                    mat[i][j] = let[curr];
                    if( cont == each ){
                        curr ++;
                        cont = 0;
                        if( curr == cont%k ) each --;
                    }
                }
            }else{
                for( int j = m-1 ; j <= 0 ; j -- ){
                    if( mat[i][j] == 'R' ) cont ++;
                    mat[i][j] = let[curr];
                    if( cont == each ){
                        curr ++;
                        cont = 0;
                        if( curr == cont%k ) each --;
                    }
                }
            }
        }

        for( int i = 0 ; i < n ; i ++ ){
            for( int j = 0 ; j < m ; j ++ ){
                cout << mat[i][j];
            }
            cout << endl ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
struct tr{
    ll a,b,c;
};
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    char c[n][m];
    ll r=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cin>>c[i][j];
            if(c[i][j]=='R'){
                c[i][j]='*';
                r++;
            }
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll ii=0,jj=0;
    for(ll i=0;i<k;i++){
        while(1){
            if(c[ii][jj]=='.' || c[ii][jj]=='*'){
                break;
            }
            jj++;
            if(jj==m){
                jj=0;
                ii++;
            }
        }
        ll count=0;
        queue<pi> q;
        q.push({ii,jj});
        if(c[ii][jj]=='*'){
            count++;
        }
        c[ii][jj]=chick[i];
        if(count==food+(i<rem)){
            continue;
        }
        bool flag=1;
        while(!q.empty()){
            pi p=q.front();
            q.pop();
            ll iii=p.ff,jjj=p.ss;
            vi x{-1,0,1,0};
            vi y{0,1,0,-1};
            for(ll j=0;j<4;j++){
                if(iii+x[j]>=0 && iii+x[j]<n && jjj+y[j]>=0 && jjj+y[j]<m && (c[iii+x[j]][jjj+y[j]]=='*' || c[iii+x[j]][jjj+y[j]]=='.')){
                    if(c[iii+x[j]][jjj+y[j]]=='*'){
                        count++;
                    }
                    c[iii+x[j]][jjj+y[j]]=c[iii][jjj];
                    if(count==food+(i<rem)){
                        flag=0;
                        while(!q.empty()){
                            pi p=q.front();
                            q.pop();
                            c[p.ff][p.ss]='.';
                        }
                        break;
                    }
                    q.push({iii+x[j],jjj+y[j]});
                }
            }
            if(!flag){
                break;
            }
        }
    }
    queue<pi> q;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]!='.'){
                q.push({i,j});
            }
        }
    }
    while(!q.empty()){
        pi p=q.front();
        q.pop();
        ll ii=p.ff,jj=p.ss;
        vi x{-1,0,1,0};
        vi y{0,1,0,-1};
        for(ll i=0;i<4;i++){
            if(ii+x[i]>=0 && ii+x[i]<n && jj+y[i]>=0 && jj+y[i]<m && c[ii+x[i]][jj+y[i]]=='.'){
                q.push({ii+x[i],jj+y[i]});
                c[ii+x[i]][jj+y[i]]=c[ii][jj];
            }
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cout<<c[i][j];
        }
        cout<<endl;
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll r=0;
    vector<char> v;
    vector<string> c(n);
    for(ll i=0;i<n;i++){
        cin>>c[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]=='R'){
                r++;
                c[i][j]='*';
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            v.pb(c[i][j]);
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll j=0,count=0;
    for(ll i=0;i<n*m;i++){
        if(v[i]=='*'){
            count++;
        }
        v[i]=chick[j];
        if(rem){
            if(count==food+1){
                j++;
                count=0;
                rem--;
            }
        }
        else{
            if(count==food){
                j++;
                count=0;
            }
        }
    }
    vector<vector<char>> ans;
    for(ll i=0;i<n;i++){
        vector<char> temp;
        for(ll j=0;j<m;j++){
            temp.pb(v[i*m+j]);
        }
        if(i%2){
            reverse(all(temp));
        }
        ans.pb(temp);
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll r=0;
    vector<char> v;
    vector<string> c(n);
    for(ll i=0;i<n;i++){
        cin>>c[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]=='R'){
                r++;
                c[i][j]='*';
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            v.pb(c[i][j]);
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll j=0,count=0;
    for(ll i=0;i<n*m;i++){
        if(v[i]=='*'){
            count++;
        }
        v[i]=chick[j];
        if(rem){
            if(count==food+1){
                j++;
                count=0;
                rem--;
            }
        }
        else{
            if(count==food){
                j++;
                count=0;
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n*m;i++){
        if(i && i%m==0){
            cout<<endl;
        }
        cout<<v[i];
    }
    cout<<endl;
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll r=0;
    vector<char> v;
    vector<string> c(n);
    for(ll i=0;i<n;i++){
        cin>>c[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]=='R'){
                r++;
                c[i][j]='*';
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            v.pb(c[i][j]);
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll j=0,count=0;
    for(ll i=0;i<n*m;i++){
        if(v[i]=='*'){
            count++;
        }
        v[i]=chick[j];
        if(rem){
            if(count==food+1){
                j++;
                count=0;
                rem--;
            }
        }
        else{
            if(count==food){
                j++;
                count=0;
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n*m;i++){
        if(i && i%m==0){
            cout<<endl;
        }
        cout<<v[i];
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll r=0;
    vector<char> v;
    vector<string> c(n);
    for(ll i=0;i<n;i++){
        cin>>c[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]=='R'){
                r++;
                c[i][j]='*';
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(i%2){
            reverse(all(c[i]));
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            v.pb(c[i][j]);
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll j=0,count=0;
    for(ll i=0;i<n*m;i++){
        if(j==k){
            while(i<n*m){
                v[i]=chick[j-1];
                i++;
            }
            break;
        }
        if(v[i]=='*'){
            count++;
        }
        v[i]=chick[j];
        if(rem){
            if(count==food+1){
                j++;
                count=0;
                rem--;
            }
        }
        else{
            if(count==food){
                j++;
                count=0;
            }
        }
    }
    vector<vector<char>> ans;
    for(ll i=0;i<n;i++){
        vector<char> temp;
        for(ll j=0;j<m;j++){
            temp.pb(v[i*m+j]);
        }
        if(i%2){
            reverse(all(temp));
        }
        ans.pb(temp);
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
struct tr{
    ll a,b,c;
};
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    char c[n][m];
    ll r=0;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cin>>c[i][j];
            if(c[i][j]=='R'){
                c[i][j]='*';
                r++;
            }
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll ii=0,jj=0;
    for(ll i=0;i<k;i++){
        while(1){
            if(c[ii][jj]=='.' || c[ii][jj]=='*'){
                break;
            }
            jj++;
            if(jj==m){
                jj=0;
                ii++;
            }
        }
        ll count=0;
        queue<pi> q;
        q.push({ii,jj});
        if(c[ii][jj]=='*'){
            count++;
        }
        c[ii][jj]=chick[i];
        if(count==food+(i<rem)){
            continue;
        }
        bool flag=1;
        while(!q.empty()){
            pi p=q.front();
            q.pop();
            ll iii=p.ff,jjj=p.ss;
            vi x{-1,0,1,0};
            vi y{0,1,0,-1};
            for(ll j=0;j<4;j++){
                if(iii+x[j]>=0 && iii+x[j]<n && jjj+y[j]>=0 && jjj+y[j]<m && (c[iii+x[j]][jjj+y[j]]=='*' || c[iii+x[j]][jjj+y[j]]=='.')){
                    q.push({iii+x[j],jjj+y[j]});
                    if(c[iii+x[j]][jjj+y[j]]=='*'){
                        count++;
                    }
                    c[iii+x[j]][jjj+y[j]]=c[iii][jjj];
                    if(count==food+(i<rem)){
                        flag=0;
                        break;
                    }
                }
            }
            if(!flag){
                break;
            }
        }
    }
    queue<pi> q;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(c[i][j]!='.'){
                q.push({i,j});
            }
        }
    }
    while(!q.empty()){
        pi p=q.front();
        q.pop();
        ll ii=p.ff,jj=p.ss;
        vi x{-1,0,1,0};
        vi y{0,1,0,-1};
        for(ll i=0;i<4;i++){
            if(ii+x[i]>=0 && ii+x[i]<n && jj+y[i]>=0 && jj+y[i]<m && c[ii+x[i]][jj+y[i]]=='.'){
                q.push({ii+x[i],jj+y[i]});
                c[ii+x[i]][jj+y[i]]=c[ii][jj];
            }
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cout<<c[i][j];
        }
        cout<<endl;
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define sz(a)               ll((a).size())
#define ll                  long long
#define int                 ll
#define pb                  push_back
#define ld                  long double
#define mp                  make_pair
#define vi                  vector<ll>
#define vii                  vector<pi>
#define endl                "\n"
#define ff                  first
#define ss                  second
#define all(c)              (c).begin(),(c).end()
#define allr(c)             (c).rbegin(),(c).rend()
#define input(a,n)          for(long long i=0;i<n;i++)cin>>a[i]
#define output(a,n)         for(long long i=0;i<n;i++)cout<<a[i]<<" "
#define inputt(a,n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)cin>>a[i][j]
#define outputt(a,n,m)      for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define reset(a,n)          memset(a,n,sizeof(a))   // n can only be 0 or -1
#define pi                  pair<ll,ll>
#define inf                 LLONG_MAX
#define N                   1000000
#define minp                vector<ll>, greater<ll>
#define M                   1000000007
#define MM                  1000000009
#define pie                 3.1415926535897932384626433832795
#define                     she_taught_me_to_code cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);cin.tie(NULL);    clock_t startTime=clock(); cout<<fixed<<setprecision(12);
#define time     cout<<(double(clock()-startTime )/(double)CLOCKS_PER_SEC)*1000<<" ms"<<endl;
#define debug(k) cout<<"\t-> "<<#k<<" = "<<k<<endl;

/*************************************************Debugging Tips****************************************************/

// If aplying ceil, floor, pow, etc convert it llo lleger
// Whenever using stacks,queues,etc always check that their top / front / back elements are not accessed when they are empty, thus causing runtime error
// Always consider the possibility of binary search
// Think twice before using greedy
// Always check that any index is not going to be negative
// Remember losing 1 or 2 minutes is better than a penalty of 10 minutes
// Use log2 instead of log()/log(2) to avoid shitty errors
// If declaring a large array, define it globally
// Always initialise anything while declaring, which will not be taken as input
// In case of a problem having decimal calculations, try declaring everything in double rather than typecasting in each step
// Always declare the array with n+5 elements to avoid unexpected errors
// Every problem cannot be solved by DFS easily, think of BFS too
// Never use accumulate, it will probably cause overflow errors
// Use __builtin_popcountll(mask) for counting number of set bits in mask to avoid TLE
// In some problems it has some constant solution for large n and a polynomial solution for small n so that it can be easily solved, keep that in mind
// Use upper_bound(all(v),x,greater<ll>()) for reverse of upper_bound, i.e finding greatest element less than x, v should be reverse sorted
// Use s.lower_bound(x) in set and multiset, the other one has linear complexity
// pow(a,b) does not provide exact results sometimes, use a loop instead

/*******************************************************************************************************************/

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}
ll min(ll a,ll b){
    return a<b?a:b;
}
ll max(ll a,ll b){
    return a>b?a:b;
}
ll max3(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll max4(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}
ll min3(ll a,ll b,ll c){
    return min(min(a,b),c);
}
ll min4(ll a,ll b,ll c,ll d){
    return min(min(a,b),min(c,d));
}
ll po(ll x,ll n,ll mod=M){
    if(n==0){
        return 1;
    }
    ll m=po(x,n/2,mod);
    m*=m;
    m%=mod;
    if(n%2){
        m*=x;
        m%=mod;
    }
    return m;
}
bool comp(pi p1,pi p2){
    return p1.ss<=p2.ss;
}
void solve(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll r=0;
    vector<char> v;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            char c;
            cin>>c;
            if(c=='R'){
                c='*';
                r++;
            }
            v.pb(c);
        }
    }
    ll food=r/k;
    string chick="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    ll rem=r%k;
    ll j=0,count=0;
    for(ll i=0;i<n*m;i++){
        if(v[i]=='*'){
            count++;
        }
        v[i]=chick[j];
        if(rem>0){
            if(count==food+1){
                j++;
                count=0;
            }
        }
        else{
            if(count==food){
                j++;
                count=0;
            }
        }
        rem--;
        if(i && i%m==0){
            cout<<endl;
        }
        cout<<v[i];
    }
}
int32_t main(){

    she_taught_me_to_code

    // freopen("input.txt","r",stdin);
    // freopen("input.txt","w",stdout);

    ll t;
    cin>>t;
    while(t--){
        solve();
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int p, n, m;
char s[maxn][maxn];
int a[maxn][maxn];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
struct node{ int x, y; };
char idx(int x)
{
    x--;
    if(x >= 0 && x <= 9) return '0'+x;
    if(x <= 35) return x-10+'a';
    return x-36+'A';
}
void bfs(int x,int y,int goal)
{
    node tmp;
    queue<node> q;
    q.push((node){x,y});
    int num = 0;
    while(!q.empty()){
        tmp = q.front(); q.pop();
        if(a[tmp.x][tmp.y]) continue;
        if(s[tmp.x][tmp.y] == 'R') num++;
        a[tmp.x][tmp.y] = p;
        if(num == goal) break;
        for(int i = 0; i < 4; i++){
            int tx = tmp.x+dx[i];
            int ty = tmp.y+dy[i];
            if(tx < 1 || tx > n || ty < 1 || ty > m || a[tx][ty]) continue;
            q.push((node){tx,ty});
        }
    }
}
int main()
{
    int t, k;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&m,&k);
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            scanf("%s",s[i]+1);
            for(int j = 1; j <= m; j++){
                if(s[i][j] == 'R') cnt++;
                a[i][j] = 0;
            }
        }
        p = 1;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(p > k) break;
                if(a[i][j]) continue;
                int tmp = cnt/k;
                if(p <= cnt%k) tmp++;
                bfs(i,j,tmp);
                p++;
            }
            if(p > k) break;
        }
        int tmp;
        for(int i = 1; i <= n; i++){
            tmp = a[i-1][1];
            for(int j = 1; j <= m; j++){
                if(!a[i][j]) a[i][j] = tmp;
                else tmp = a[i][j];
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                printf("%c",idx(a[i][j]));
            }
            printf("\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
char s[maxn][maxn];
int a[maxn][maxn];
char idx(int x)
{
    x--;
    if(x >= 0 && x <= 9) return '0'+x;
    if(x <= 35) return x-10+'a';
    return x-36+'A';
}
int main()
{
    int t, n, m, k;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&m,&k);
        int cnt = 0;
        for(int i = 1; i <= n; i++){
            scanf("%s",s[i]+1);
            for(int j = 1; j <= m; j++){
                if(s[i][j] == 'R') cnt++;
            }
        }
        int p = 1, flag = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(s[i][j] != 'R'){ a[i][j] = p; continue; }
                if(p <= cnt%k){
                    if(flag == cnt/k+1) p++, flag = 0;
                }
                else if(flag == cnt/k) p++, flag = 0;
                if(flag < cnt/k){
                    a[i][j] = p; flag++;
                    continue;
                }
                if(p <= cnt%k){
                    a[i][j] = p; flag++;
                    continue;
                }
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                printf("%c",idx(a[i][j]));
            }
            printf("\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int p, n, m, cnt, k;
char s[maxn][maxn];
int a[maxn][maxn];
char idx(int x)
{
    x--;
    if(x >= 0 && x <= 9) return '0'+x;
    if(x <= 35) return x-10+'a';
    return x-36+'A';
}
void dfs(int x,int y,int num,int goal,int op)
{
    a[x][y] = p;
    if(s[x][y] == 'R') num++;
    if(num == goal){
        p++;
        if(p > k) return ;
        int tmp = cnt/k;
        if(p <= cnt%k) tmp++;
        if(op){
            if(y == 1) dfs(x+1,1,0,tmp,0);
            else dfs(x,y-1,0,tmp,1);
        }
        else{
            if(y == m) dfs(x+1,m,0,tmp,1);
            else dfs(x,y+1,0,tmp,0);
        }
    }
    else{
        if(op){
            if(y == 1) dfs(x+1,1,num,goal,0);
            else dfs(x,y-1,num,goal,1);
        }
        else{
            if(y == m) dfs(x+1,m,num,goal,1);
            else dfs(x,y+1,num,goal,0);
        }
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&m,&k);
        cnt = 0;
        for(int i = 1; i <= n; i++){
            scanf("%s",s[i]+1);
            for(int j = 1; j <= m; j++){
                if(s[i][j] == 'R') cnt++;
                a[i][j] = 0;
            }
        }
        p = 1;
        int tmp = cnt/k;
        if(p <= cnt%k) tmp++;
        dfs(1,1,0,tmp,0);
        int tmp = a[1][1];
        for(int i = 1; i <= m; i++){
            if(!a[1][i]) a[1][i] = tmp;
            else tmp = a[1][i];
        }
        for(int i = 2; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(a[i][j]) continue;
                a[i][j] = a[i-1][j];
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                printf("%c",idx(a[i][j]));
            }
            printf("\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 105;
int p, n, m, cnt, k;
char s[maxn][maxn];
int a[maxn][maxn];
char idx(int x)
{
    x--;
    if(x >= 0 && x <= 9) return '0'+x;
    if(x <= 35) return x-10+'a';
    return x-36+'A';
}
void dfs(int x,int y,int num,int goal,int op)
{
    a[x][y] = p;
    if(s[x][y] == 'R') num++;
    if(num == goal){
        p++;
        if(p > k) return ;
        int tmp = cnt/k;
        if(p <= cnt%k) tmp++;
        if(op){
            if(y == 1) dfs(x+1,1,0,tmp,0);
            else dfs(x,y-1,0,tmp,1);
        }
        else{
            if(y == m) dfs(x+1,m,0,tmp,1);
            else dfs(x,y+1,0,tmp,0);
        }
    }
    else{
        if(op){
            if(y == 1) dfs(x+1,1,num,goal,0);
            else dfs(x,y-1,num,goal,1);
        }
        else{
            if(y == m) dfs(x+1,m,num,goal,1);
            else dfs(x,y+1,num,goal,0);
        }
    }
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d",&n,&m,&k);
        cnt = 0;
        for(int i = 1; i <= n; i++){
            scanf("%s",s[i]+1);
            for(int j = 1; j <= m; j++){
                if(s[i][j] == 'R') cnt++;
                a[i][j] = 0;
            }
        }
        p = 1;
        int tmp = cnt/k;
        if(p <= cnt%k) tmp++;
        dfs(1,1,0,tmp,0);
        tmp = a[1][1];
        for(int i = 1; i <= m; i++){
            if(!a[1][i]) a[1][i] = tmp;
            else tmp = a[1][i];
        }
        for(int i = 2; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(a[i][j]) continue;
                a[i][j] = a[i-1][j];
            }
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                printf("%c",idx(a[i][j]));
            }
            printf("\n");
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n;
int const maxn=1e4;
struct mang{
    int index;
    int number;
};
mang a[maxn];
bool cc(mang b,mang c){
    return (b.number<c.number);
}
int b[maxn];
int main(){
    cin>>n;
    int x;
    bool t=false;
    for(int i=1;i<=n;i++){
        cin>>x;
        b[i]=x;
        a[i].number=x;
        a[i].index=i;
    }
    sort(a+1,a+n+1,cc);
    for(int i=1;i<n;i++){
        if(a[i].number==a[i+1].number){
            a[i+1].index=a[i].index;
        }
    }
    int ans=1;
    for(int i=1;i<n;i++){
        if(a[i+1].index<a[i].index) ans++;
    }
    for(int i=1;i<n;i++){
        if(b[i+1]>=b[i] and b[1]==0) t=true;
    }
    if(t==true) cout<<0;
    else cout<<ans;
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <algorithm>
#include <functional>
#define ll long long
using namespace std;

int main()
{
	int n, a[1000] = {}, ans = 0, j = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while (j < n)
	{
		ans += ans != 0;
		for (int i = 0; i < n; i++)
			if (a[i] != -1 && j >= a[i])
				j++, a[i] = -1;
		if (j == n)
			continue;
		ans++;
		for (int i = n - 1; i >= 0; i--)
			if (a[i] != -1 && j >= a[i])
				j++, a[i] = -1;
	}
	cout << ans;
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <random>
using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    int a[1010];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int parts = 0, ans = 0;
    while (1) {
        if (ans % 2 == 0) {
            for (int i = 0; i < n; i++) {
                if (a[i] != -1 && parts >= a[i]) {
                    a[i] = -1;
                    parts++;
                }
            }
        } else {
            for (int i = n - 1; i >= 0; i--) {
                if (a[i] != -1 && parts >= a[i]) {
                    a[i] = -1;
                    parts++;
                }
            }
        }
        if (parts == n)
            break;
        ans++;
    }

    cout << ans;
}


#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int  n, m, k, dem, maxx, rs, sum;
int resources;
//long long a[100005], rs;
//map<string,int>rs;
#define N 100005
int a[1005];
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int d = 1;
	a[n+1] = 1e9;
	a[0] = 1e9;
	for (int i = 1; resources < n; )
	{
		if (a[i] <= resources) { resources++; a[i] = 1e9; }
		if (i <= n&&i >= 1) i += d;
		else
		{
			i -= d;
			if (d == 1) d = -1;
			else d = 1;
			rs++;
		}
	}
	cout << rs;
}


#include <iostream>
using namespace std;
#include <vector>

int main(){
    /*int n;
    cin >> n;
    int row[50];
    int column[50];
    for (int i = 0; i < n; i++){
        row[i] = 0;
        column[i] = 0;

    }
    int Row;
    int Col;
    n = n * n;
    for (int i = 0; i < n; i++){
        cin >> Row;
        cin >> Col;
        if (row[Row] == 1){
            continue;
        }
        if (column[Col] == 1){
            continue;
        }
        row[Row] = 1;
        column[Col] = 1;
        cout << i + 1 << " ";
    }*/

    int n;
    cin >> n;

    vector<int> list;
    int temp;
    for (int i = 0; i < n; i++){
        cin >> temp;
        list.push_back(temp);
    }
    int itemCounter = 0;
    int turnCounter = 0;

    for (int j = 0; j < 1000; j++){
        if (list.size() <= 0){
            break;
        }
        for (int i = 0; i < list.size(); i++){
            if (itemCounter >= list[i]){
                itemCounter++;
                list.erase(list.begin() + i);
                i--;
            }
        }

        if (list.size() <= 0){
            break;
        }
        turnCounter++;
        for (int i = list.size() - 1; i >= 0; i--){
            if (itemCounter >= list[i]){
                itemCounter++;
                list.erase(list.begin() + i);
            }
        }
        if (list.size() <= 0){
            break;
        }
        turnCounter++;
    }

    cout << turnCounter;
}


int main(){
    /*int n;
    cin >> n;
    int row[50];
    int column[50];
    for (int i = 0; i < n; i++){
        row[i] = 0;
        column[i] = 0;

    }
    int Row;
    int Col;
    n = n * n;
    for (int i = 0; i < n; i++){
        cin >> Row;
        cin >> Col;
        if (row[Row] == 1){
            continue;
        }
        if (column[Col] == 1){
            continue;
        }
        row[Row] = 1;
        column[Col] = 1;
        cout << i + 1 << " ";
    }*/

    int n;
    cin >> n;

    vector<int> list;
    int temp;
    for (int i = 0; i < n; i++){
        cin >> temp;
        list.push_back(temp);
    }
    int itemCounter = 0;
    int turnCounter = 0;

    for (int j = 0; j < 1000; j++){
        if (list.size() <= 0){
            break;
        }
        for (int i = 0; i < list.size(); i++){
            if (itemCounter >= list[i]){
                itemCounter++;
                list.erase(list.begin() + i);
                i--;
            }
        }

        if (list.size() <= 0){
            break;
        }
        turnCounter++;
        for (int i = list.size() - 1; i >= 0; i--){
            if (itemCounter >= list[i]){
                itemCounter++;
                list.erase(list.begin() + i);
            }
        }
        if (list.size() <= 0){
            break;
        }
        turnCounter++;
    }

    cout << turnCounter;
}


#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <cmath>

#define mp make_pair
#define ll long long
#define pb push_back

using namespace std;

const double PI=3.1415926535897932384626433832795;
const ll INF=1e9+7;
const double EPS=1/1e9;
const ll MOD=1000000007;
const int N=100002;//1010;

void solve(){

	int n;
	int x,s=0;
	vector<int> a;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		a.pb(x);
	}
	int ans=0;
	while(true){
		for(int i=0;i<n;i++)
			if(a[i]<=s)
				s++,a[i]=n+1;
		if(s==n)
			break;
		ans++;

		for(int i=n-1;i>=0;i--)
			if(a[i]<=s)
				s++,a[i]=n+1;
		if(s==n)
			break;
		ans++;
	}
	cout << ans;
}

int main(){

//	freopen( "cycle2.in", "r", stdin );
	//freopen( "cycle2.out", "w", stdout );

	int k1=1;
	while (k1--)
		solve();

	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
using namespace std;
//ifstream cin("input.txt");
//ofstream cout("output.txt");
typedef long long LL;
const LL INF = 1e9;
const double eps = 1e-8;
vector<vector<int> > g;
int main()
{
	int n,m, x,y;
	cin>>n;
	vector<int> a;
	int elem;
	for(int i=1; i<=n*n; i++)
	{
		cin>>elem;
		a.push_back(elem);
	}
	sort(a.begin(), a.end());
	int res = 0;
	for(int i=1; i<n; i++)
	{
		if(a[i]<a[i-1]) res++;
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
using namespace std;
//ifstream cin("input.txt");
//ofstream cout("output.txt");
typedef long long LL;
const LL INF = 1e9;
const double eps = 1e-8;
vector<vector<int> > g;
int main()
{
	int n,m, x,y;
	cin>>n;
	vector<pair<int, int> > a;
	vector<int> pos;
	int elem;
	for(int i=1; i<=n; i++)
	{
		cin>>elem;
		a.push_back(make_pair(elem, i));
	}
	bool flag = true;
	int c = 0;
	int res = 0;
	vector<bool> used(n, false);
	while(c!=n)
	{
		if(flag)
		{
			for(int i=0; i<n; i++)
			{
				if(!used[i])
					if(a[i].first<=c)
					{
						c++;
				used[i] = true;
					}
			}
		}
		else
		{
			for(int i = n-1; i>=0; i--)
			{
				if(!used[i])
					if(a[i].first<=c)
					{
						c++;
				used[i] = true;
					}
			}
		}
		if(c<n) res++;
		flag = !flag;
	}
	cout<<res;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<sstream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>

#define P pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;

int main(){
	int n, pos=0, orient=0, kol=0;
	scanf("%d", &n);
	vector <int> a(n);
	vector <bool> used(n, 0);
	for (int i=0; i<n; i++)
		scanf("%d", &a[i]);

	for (int i=0; i<n; i++){
		bool f=0;
		if (orient==0){
			for (int j=pos; j<n; j++)
				if (a[j]<=i && !used[j]) {f=1; used[j]=1; pos=j; break;}
			if (!f)
				for (int j=0; j<pos; j++)
					if (a[j]<=i && !used[j]) {used[j]=1; orient=1; kol++; pos=j; break;}
		}
		else{
			for (int j=0; j<=pos; j++)
				if (a[j]<=i && !used[j]) {f=1; used[j]=1; pos=j; break;}
			if (!f)
				for (int j=pos+1; j<n; j++)
					if (a[j]<=i && !used[j]) {used[j]=1; orient=0; kol++; pos=j; break;}
		}
	}
	printf("%d", kol);
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<sstream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>

#define P pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;

int main(){
	int n, pos=0, orient=0, kol=0;
	scanf("%d", &n);
	vector <int> a(n);
	vector <bool> used(n, 0);
	for (int i=0; i<n; i++)
		scanf("%d", &a[i]);

	for (int i=0; i<n; i++){
		bool f=0;
		if (orient==0){
			for (int j=pos; j<n; j++)
				if (a[j]<=i && !used[j]) {f=1; used[j]=1; pos=j; break;}
			if (!f)
				for (int j=pos-1; j>=0; j--)
					if (a[j]<=i && !used[j]) {used[j]=1; orient=1; kol++; pos=j; break;}
		}
		else{
			for (int j=pos; j>=0; j--)
				if (a[j]<=i && !used[j]) {f=1; used[j]=1; pos=j; break;}
			if (!f)
				for (int j=pos+1; j<n; j++)
					if (a[j]<=i && !used[j]) {used[j]=1; orient=0; kol++; pos=j; break;}
		}
	}
	printf("%d", kol);
}


#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n, x, count = -1, c = 0;
	cin >> n;
	vector<int> V;
	for (int i = 0; i < n; i++) {
		cin >> x;
		V.push_back(x);
	}
	while (V.size() > 0) {
		count++;
		if (count % 2 == 0)
			for (int i = 0; i < V.size(); i++) {
				if (V[i] <= c) {
					c++;
					V.erase(V.begin() + i);
					i--;
				}
			}
		else
			for (int i = V.size() - 1; i >= 0; i--) {
				if (V[i] <= c) {
					c++;
					V.erase(V.begin() + i);
				}
			}
	}
	cout << count << endl;
	return 0;
}


#include<iostream>
using namespace std;
int a[1002];
bool flag[1002];
int minvalue = 1001,minpos=1001;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int now = 0, cnt = 0;//统计第几次转弯
	while (1) {
		if (cnt % 2 == 0) {//正方向行走
			for (int i = 1; i <= n; ++i) {
				if (flag[i])
					continue;
				if (a[i] <= now) {
					flag[i] = 1;
					now++;
				}
			}
		}
		else {
			for (int i = n; i >= 1; --i) {
				if (flag[i])
					continue;
				if(a[i] <= now) {
					flag[i] = 1;
					now++;
				}
			}
		}
		if (now == n)
			break;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <math.h>
#include <cmath>
#include <sstream>
#include <queue>
#include <string>
#include <cstdio>

using namespace std;

#define MAXN 10000000+99
#define ll   long long
#define Pi   3.1415926
#define Mp   make_pair
#define test freopen("a.in" , "r" , stdin)
#define mod  1000000007

int  arr[MAXN];

int main()
{
	//test;
	ll int n,ans =0 , point=0,check=0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	bool sw = 0;
	int j = 0;
	while (true)
	{
		if (arr[j] <= point && arr[j] != -1)
		{
			point++, arr[j] = -1;
			check++;
		}
		if (check == n)
			break;
		if ((j == n - 1 && sw==0) || (j <= 0 && sw==1))
		{
			sw == 0 ? sw = 1 : sw = 0;
			ans++;
		}

		if (sw == 1)
			j--;
		else
			j++;

	}
	cout << ans << endl;
	return 0;

}


#include <iostream>
using namespace std;
const int N = 100000;
int main(){
	int n, sm;
	cin >> n;
	int a[N];

	for (int i = 1; i <=n; i++){
		cin >> a[i];
	}

	sm = -1; int s =0;

	while (s < n){
	//	cout<<"new"<<endl;

		sm++;

		for (int i = 1; i<=n; i++){
			if (s >=a[i] && a[i] != -1){
				a[i] = -1;
				s++;
			}
		//	cout << "i="<<i<<" s="<<s<<" a[i]= "<<a[i]<< endl;
		}

		if (s >= n) break;
		sm++;
	//	cout<<"gfgf"<<endl;

		for (int i = n; i>0; i--){
			if (s>=a[i] && a[i] != -1){
				a[i] = -1;
				s++;
			}
		}
	//	cout<<"sum = "<<sm<<endl;
	}
	cout << sm<< endl;
	//system("pause");
	return 0;
}


#include <iostream>
using namespace std;
const int N = 100000;
int main(){
	int n, sm;
	cin >> n;
	int a[N];

	for (int i = 0; i <n; i++){
		cin >> a[i];
	}

	sm = -1; int s =0;

	while (s < n){
	//	cout<<"new"<<endl;

		for (int i = 0; i<n; i++){
			if (s >=a[i] && a[i]>=0){
				a[i] = -1;
				s++;
			}
		//	cout << "i="<<i<<" s="<<s<<" a[i]= "<<a[i]<< endl;
		}
		sm++;
		if (s >= n) break;
		sm++;
	//	cout<<"gfgf"<<endl;
		for (int i = n-1; i>0; i--){
			if (s>=a[i] && a[i]>=0){
				a[i] = -1;
				s++;
			}
		}
	//	cout<<"sum = "<<sm<<endl;
	}
	cout << sm<< endl;
	//system("pause");
	return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int a[1000], hacked[1000];

int allHacked(const int &l, const int &r)
{
    for(int i = l; i <= r; ++i)
    {
        if(hacked[i] == 0) return 0;
    }
    return 1;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
        hacked[i] = 0;
    }
    int collected = 0;
    int left = 0, right = n-1, turns = 0;
    while(allHacked(left, right) == 0)
    {
        //cout << left << "  " << right << endl;
        for(int i = left; i <= right; ++i)
        {
            //cout <<"expl " << i << endl;
            if(a[i] <= collected)
            {
                hacked[i] = 1;
                ++collected;
            }
        }
        if(allHacked(left, right) == 0) ++turns;
        else break;
        while(hacked[right] == 1) --right;
        while(hacked[left] == 1) ++left;
        //cout << left << "  " << right << endl;
        for(int i = right; i >= left; --i)
        {
            //cout <<"expl " << i << endl;
            if(a[i] <= collected)
            {
                hacked[i] = 1;
                ++collected;
            }
        }
        if(allHacked(left, right) == 0) ++turns;
        else break;
        while(hacked[right] == 1) --right;
        while(hacked[left] == 1) ++left;
    }
    cout << turns;
    return 0;
}


#include <iostream>
#include <stdio.h>

using namespace std;

int a[1000], hacked[1000];

int allHacked(const int &l, const int &r)
{
    for(int i = l; i <= r; ++i)
    {
        if(hacked[i] == 0) return 0;
    }
    return 1;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
        hacked[i] = 0;
    }
    int collected = 0;
    int left = 0, right = n-1, turns = 0;
    while(1)
    {
        if(allHacked(left, right) == 0)
        {
            if(turns > 0) ++turns;
        }
        else break;
        while(hacked[right] == 1) --right;
        while(hacked[left] == 1) ++left;
        //cout << left << "  " << right << " " << turns << " now" << endl;
        for(int i = left; i <= right; ++i)
        {
            //cout << "expl " << i;
            if(hacked[i] == 1)
            {
                //cout << " already hacked" << endl;
                continue;
            }
            if(a[i] <= collected)
            {
                hacked[i] = 1;
                ++collected;
                //cout << "  hacked " << collected;
            }
            //cout << endl;
        }
        if(allHacked(left, right) == 0) ++turns;
        else break;
        while(hacked[right] == 1) --right;
        while(hacked[left] == 1) ++left;
        //cout << left << "  " << right << " " << turns << " now" << endl;
        for(int i = right; i >= left; --i)
        {
            //cout << "expl " << i;
            if(hacked[i] == 1)
            {
                //cout << " already hacked" << endl;
                continue;
            }
            if(a[i] <= collected)
            {
                hacked[i] = 1;
                ++collected;
                //cout << "  hacked " << collected;
            }
            //cout << endl;
        }
        if(allHacked(left, right) == 1)
        {
            //cout << "all hacked at the end" << endl;
            break;
        }
    }
    cout << turns;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
#define CRL(a) memset(a,0,sizeof(a))
typedef __int64 ll;
#define T 1005
int a[T],b[T];
int main(){
    /*freopen("input.txt","r",stdin);*/
    int n,m,i,cnt,now;
    while(~scanf("%d",&n))
    {
        CRL(b);
        for(i=0;i<n&&scanf("%d",&a[i]);++i);
        cnt = now = 0;
        while(now<n)
        {
            if(cnt&1){
                for(i=n-1;i>=0;--i){
                    if(a[i]<=now&&!b[i]){
                        b[i]=1;
                        now++;
                    }
                }
            }
            else
            {
                for(i=0;i<n;++i){
                    if(a[i]<=now&&!b[i]){
                        now++;
                        b[i]=1;
                    }
                }
            }
            cnt++;
        }
        printf("%d\n",cnt-1);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
#define CRL(a) memset(a,0,sizeof(a))
typedef __int64 ll;
#define T 1005
int a[T],b[T];
int main(){
   /* freopen("input.txt","r",stdin);*/
    int n,m,i,j,k,c;
    while(~scanf("%d",&n))
    {
        if(n==1){
            printf("0\n");
            continue;
        }
        CRL(a),CRL(b);
        for(i=0;i<n;++i)
        {
            scanf("%d",&k);
            a[i]=b[i]=k;
        }
        sort(b,b+n);
        int new_n=unique(b,b+n)-b;
        k=b[c=0];j=1;
        for(i=0;i<n&&c<new_n;++i){
            if(a[i]==k){
                k=b[++c];
            }
            if(c<new_n&&i==n-1)i=-1,j++;

        }
        printf("%d\n",j);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
#define CRL(a) memset(a,0,sizeof(a))
typedef __int64 ll;
#define T 1005
int a[T],b[T];
int main(){
   /* freopen("input.txt","r",stdin);*/
    int n,m,i,j,k,c;
    while(~scanf("%d",&n))
    {
        CRL(a),CRL(b);
        for(i=0;i<n;++i)
        {
            scanf("%d",&k);
            a[i]=b[i]=k;
        }
        if(n==1){
            printf("0\n");
            continue;
        }
        sort(b,b+n);
        int new_n=unique(b,b+n)-b;
        k=b[c=0];j=1;
        for(i=0;i<n&&c<new_n;++i){
            if(a[i]==k){
                k=b[++c];
            }
            if(c<new_n&&i==n-1)i=-1,j++;

        }
        printf("%d\n",j);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cstdio>
using namespace std;
#define CRL(a) memset(a,0,sizeof(a))
typedef __int64 ll;
#define T 1005
int a[T],b[T];
int main(){
   /* freopen("input.txt","r",stdin);*/
    int n,m,i,j,k,c;
    while(~scanf("%d",&n))
    {
        CRL(a),CRL(b);
        for(i=0;i<n;++i)
        {
            scanf("%d",&k);
            a[i]=b[i]=k;
        }
        sort(b,b+n);
        int new_n=unique(b,b+n)-b;
        k=b[c=0];j=1;
        for(i=0;i<n&&c<new_n;++i){
            if(a[i]==k){
                k=b[++c];
            }
            if(c<new_n&&i==n-1)i=-1,j++;

        }
        printf("%d\n",j);
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include <fstream>
#include<math.h>
#include<iomanip>
#include<string>
#include<bitset>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int n;
int a[1001];
int used[1001];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    int ans=0;
    int kol=0;
    while(kol!=n)
    {
        for(int i=1;i<=n;i++)
        if((a[i]<=kol)&&(used[i]==0))
        {
            used[i]=1;
            kol++;
        }
        if(kol==n)
        break;
        else
        ans++;
        for(int i=n;i>=1;i--)
        if((a[i]<=kol)&&(used[i]==0))
        {
            used[i]=1;
            kol++;
        }
        if(kol==n)
        break;
        else
        ans++;
    }
    cout<<ans;
  	return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(){
	int n;
	int dir_changes = 0;
	// n = 7;
	scanf("%d\n", &n);
	int lvl = 0;
	int dir = 1;
	int index = 0;
	int *comps = new int[n];
	while (index < n) scanf("%d ", &comps[index++]);
	index = 0;
	while (true){
		if (comps[index] <= lvl && comps[index] != -1) lvl++, comps[index] = -1;
		if (lvl == n) break;
		if (index + dir < 0 || index + dir >= n) dir *= -1, dir_changes++;
		index += dir;
	}
	printf("%d", dir_changes);
	delete[] comps;
	getchar();
	return 0;
}