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;
}

Codeforce 1255 Round #601 (Div. 2)D. Feeding Chicken (模拟)的更多相关文章

  1. Codeforce 1255 Round #601 (Div. 2) C. League of Leesins (大模拟)

    Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the L ...

  2. Codeforce 1255 Round #601 (Div. 2)B. Fridge Lockers(思维)

    Hanh lives in a shared apartment. There are nn people (including Hanh) living there, each has a priv ...

  3. Codeforce 1255 Round #601 (Div. 2) A. Changing Volume (贪心)

    Bob watches TV every day. He always sets the volume of his TV to bb. However, today he is angry to f ...

  4. Codeforces Round #601 (Div. 2) D Feeding Chicken

    //为了连贯,采取一条路形式,从第一行开始 也就是s型 #include <bits/stdc++.h> using namespace std; ; char str[MAXN][MAX ...

  5. Codeforces Round #601 (Div. 2)D(蛇形模拟)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; vector<char>an ...

  6. 【cf比赛记录】Codeforces Round #601 (Div. 2)

    Codeforces Round #601 (Div. 2) ---- 比赛传送门 周二晚因为身体不适鸽了,补题补题 A // http://codeforces.com/contest/1255/p ...

  7. Codeforces Round #601 (Div. 2)

    传送门 A. Changing Volume 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/19 22:37:33 */ #include ...

  8. Codeforces Round #368 (Div. 2) B. Bakery (模拟)

    Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bak ...

  9. codeforce Codeforces Round #201 (Div. 2)

    cf 上的一道好题:  首先发现能生成所有数字-N 判断奇偶 就行了,但想不出来,如何生成所有数字,解题报告 说是  所有数字的中最大的那个数/所有数字的最小公倍数,好像有道理:纪念纪念: #incl ...

随机推荐

  1. AntSword 中国蚁剑的下载安装配置(附下载文件)

    文章更新于:2020-04-11 按照惯例,需要的文件附上链接放在文首. 文件一: antSword-2.1.8.1.zip.7z 文件大小: 14.3 MB 下载链接: 中国蚁剑 v2.1.8.1 ...

  2. MySQL入门,第六部分,关系代数

    关系代数是一种集合操作为基础过程化查询语言,特点:运算对象是关系,运算结果亦为关系 一.关系代数的特点 运算对象:关系 运算结果:关系 运算符:四类 集合运算符 专门的关系运算符 算术比较符 逻辑运算 ...

  3. 【python】利用jieba中文分词进行词频统计

    以下代码对鲁迅的<祝福>进行了词频统计: import io import jieba txt = io.open("zhufu.txt", "r" ...

  4. 【Selenium02篇】python+selenium实现Web自动化:鼠标操作和键盘操作!

    一.前言 最近问我自动化的人确实有点多,个人突发奇想:想从0开始讲解python+selenium实现Web自动化测试,请关注博客持续更新! 这是python+selenium实现Web自动化第二篇博 ...

  5. 34 io流-- 打印流和对象流

    概述 io流分为字符流和字节流,具体分类相见下图 字符流:char 一些基本文本的数据传输 字节流:byte 图片.视频等用文本查看器查看不了的文件都是二进制文件,只能用字节流传输,使用字符流cp的看 ...

  6. 使用docker搭建selenium grid 分布式环境

    本文章只做docker搭建selenium grid 分布式环境步骤说明,对于selenium grid中的参数.流程.原理等不做说明.selenium grid的详细情况可查看官方文档https:/ ...

  7. 六、路由详细介绍之动态路由RIP(了解一下就行)

    动态路由分为距离矢量路由(RIP)和链路状态(OSPF和ISIS) 一.离矢量路由协议-RIP RIP协议现在基本上被淘汰. RIP动态路由协议工作原理,如上图: R12中有192.168.1.0和1 ...

  8. Android 修改应用程序字体

    在网上搜索了相关资料,研究了两种算是比较快速的改变程序字体的方法,好,先来介绍着两种方法. 首先第一种方法是重写控件(以Textview为例): 1.Android在写程序的时候谷歌早已将所有字体都默 ...

  9. 【做中学】第一个 Go 语言程序:漫画下载器

    原文地址: 第一个 Go 语言程序:漫画下载器: https://schaepher.github.io/2020/04/11/golang-first-comic-downloader 之前学了点 ...

  10. 移动硬盘临时文件太多怎么办,python黑科技帮你解决

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 星安果 PS:如果想了解更多关于python的应用,可以私信我,或者 ...