Long is a huge fan of CFC (Codeforces Fried Chicken). But the price of CFC is increasing, so he decides to breed the chicken on his own farm.

His farm is presented by a rectangle grid with rr rows and cc columns. Some of these cells contain rice, others are empty. kk chickens are living on his farm. The number of chickens is not greater than the number of cells with rice on the farm.

Long wants to give his chicken playgrounds by assigning these farm cells to his chickens. He would like to satisfy the following requirements:

  • Each cell of the farm is assigned to exactly one chicken.
  • Each chicken is assigned at least one cell.
  • The set of cells assigned to every chicken forms a connected area. More precisely, if two cells (x,y)(x,y) and (u,v)(u,v) are assigned to the same chicken, this chicken is able to walk from (x,y)(x,y) to (u,v)(u,v) by passing only its cells and moving from each cell to another cell sharing a side.

Long also wants to prevent his chickens from fighting for food. Hence he wants the difference between the maximum and the minimum number of cells with rice assigned to a chicken to be as small as possible. Please help him.

Input

Each test contains multiple test cases. The first line contains the number of test cases TT (1≤T≤2⋅1041≤T≤2⋅104). Description of the test cases follows.

The first line of each test case contains three integers rr, cc and kk (1≤r,c≤100,1≤k≤621≤r,c≤100,1≤k≤62), representing the size of Long's farm and the number of chickens Long has.

Each of the next rr lines contains cc characters, each is either "." or "R", representing an empty cell or a cell with rice. It is guaranteed that the number of chickens is not greater than the number of cells with rice on the farm.

It is guaranteed that the sum of r⋅cr⋅c over all test cases does not exceed 2⋅1042⋅104.

Output

For each test case, print rr lines with cc characters on each line. Each character should be either a lowercase English character, an uppercase English character, or a digit. Two characters should be equal if and only if the two corresponding cells are assigned to the same chicken. Uppercase and lowercase characters are considered different, so "A" and "a" belong to two different chickens.

If there are multiple optimal answers, print any.

Example

Input

4
3 5 3
..R..
...R.
....R
6 4 6
R..R
R..R
RRRR
RRRR
R..R
R..R
5 5 4
RRR..
R.R..
RRR..
R..R.
R...R
2 31 62
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR

Output

11122
22223
33333
aacc
aBBc
aBBc
CbbA
CbbA
CCAA
11114
22244
32444
33344
33334
abcdefghijklmnopqrstuvwxyzABCDE
FGHIJKLMNOPQRSTUVWXYZ0123456789

这题,我觉得比C题简单好像,假设鸡有X个,输入的时候统计大米的数量为Y个,那么设每只鸡至少拿Num=Y/X个,那么由于Y%X可能不能为0,所以有剩余,那么就会有Y%X只鸡拿了Num+1个,剩下的X-Y%X的都是拿Num个,然后蛇形转,访问到第Num个就换字符,知道访问X-Y%X个,然后按照上面的方法访问Y%X的Num+1;完事了就这么简单,放D题,小题大做。代码无,实现非常简单,不想写了。

#include<bits/stdc++.h>
using namespace std;
const int N = 105; int n, m, k;
char s[N][N];
char ans[N][N];
int Max, Min;
int need, num; char Get(int x)
{
if(x < 26)
return x + 'a';
x -= 26;
if(x < 26)
return x + 'A';
x -= 26;
return x + '0';
} void go(int x, int y, int cnt, int d)
{
if(y == m + 1)
{
++x;
y = m;
d = -1;
}
if(y == 0)
{
++x;
y=d= 1;
}
if(x > n)
return;
if(s[x][y] == 'R')
--cnt;
if(cnt == -1)
++num;
ans[x][y] = Get(num);
if(cnt == -1)
{
if(--need >= 0)
go(x, y + d, Max - 1, d);
else
go(x, y + d, Min - 1, d);
return;
}
go(x, y + d, cnt, d);
}
int main()
{
int T;
cin >> T;
while(T--)
{
cin >> n >> m >> k;
int tot = 0;
for(int i = 1; i <= n; i++)
{
cin >> (s[i] + 1);
for(int j = 1; j <= m; j++)
{
if(s[i][j] == 'R')
++tot;
}
}
Min = tot / k, Max = tot / k + 1;
need = tot - k * Min;
num = 0;
if(--need >= 0)
go(1, 1, Max, 1);
else
go(1, 1, Min, 1);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
cout << ans[i][j];
}
cout << '\n';
}
}
return 0;
}

最新文章

  1. Sass用法指南
  2. 客户端Socket
  3. PHP修改表格(增删改)
  4. python脚步管理工具supervisor=3.3.0的安装、使用。基于linux系统。
  5. trie树的建立方法汇总
  6. 路由 - ASP.NET MVC 4 系列
  7. LeetCode 笔记26 Single Number II
  8. BZOJ3238: [Ahoi2013]差异 (后缀自动机)
  9. Manacher算法 , 实例 详解 . NYOJ 最长回文
  10. iOS KVO的原理
  11. linux -- 启动时启动服务或者执行命令
  12. myeclipse中使用gradle开发项目
  13. 制作SSL证书
  14. Swift - 使用UIScrollView实现页面滚动切换
  15. django model Foreign key usage 关系型数据库 ORM
  16. python输出
  17. 【题解】Luogu P2347 砝码称重
  18. hdfs性能调优(cloudera)
  19. 【汤鸿鑫 3D太极】5年目标规划(基本功、套路、实战搏击)
  20. java结合testng,利用yaml做数据源的数据驱动实例

热门文章

  1. 通过简单的ajax验证是否存在已有的用户名
  2. linux之进程管理(一)
  3. javascript入门 之 bind() (二)
  4. 中阶d03.1 JDBCDemo
  5. iOS 头条一面 面试题
  6. 自己实现一个 DFA 串模式识别器
  7. E - Aladdin and the Flying Carpet
  8. 微信小程序 —搜索框
  9. 小小小小小flag
  10. CSRF(跨站请求伪造)学习总结