#include <bits/stdc++.h>
using namespace std;
const int N = 101;
char ans[63];
int m, n, k, a[N][N], b[N * N], cnt;
int main() {
  int test;
  cin >> test;
  for (int i = 0; i <= 25; ++i) ans[++cnt] = (char)(i + 'a');
  for (int i = 0; i <= 25; ++i) ans[++cnt] = (char)(i + 'A');
  for (int i = 0; i <= 9; ++i) ans[++cnt] = (char)(i + '0');
  while (test--) {
    cin >> m >> n >> k;
    int n1 = 0, rice = 0;
    for (int i = 1; i <= m; ++i)
      for (int j = 1; j <= n; ++j) {
        char x;
        cin >> x;
        if (x == '.')
          a[i][j] = 0;
        else
          a[i][j] = 1, ++rice;
      }
    for (int i = 1; i <= m; ++i) {
      if (i % 2)
        for (int j = 1; j <= n; ++j) {
          b[++n1] = a[i][j];
          a[i][j] = n1;
        }
      else
        for (int j = n; j >= 1; --j) {
          b[++n1] = a[i][j];
          a[i][j] = n1;
        }
    }
    int sl = rice / k;
    int du = rice % k;
    int ga = 1, dem = 0;
    if (b[1]) ++dem;
    b[1] = 1;
    for (int i = 2; i <= n1; ++i) {
      if (!b[i]) {
        b[i] = b[i - 1];
        continue;
      }
      if ((dem == sl && du == 0) || dem > sl) {
        ++ga;
        dem = 0;
      } else if (dem == sl)
        du--;
      ++dem;
      b[i] = ga;
    }
    for (int i = 1; i <= m; ++i) {
      for (int j = 1; j <= n; ++j) cout << ans[b[a[i][j]]];
      cout << '\n';
    }
  }
}
