QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#68886#5240. Łamigłówka [C]loirid10 ✓39ms20996kbC++148.5kb2022-12-21 17:27:272022-12-21 17:27:28

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-21 17:27:28]
  • 评测
  • 测评结果:10
  • 用时:39ms
  • 内存:20996kb
  • [2022-12-21 17:27:27]
  • 提交

answer

#include <cstdio>
#include <cstdlib>

int n,m,k,i,j,cnt,tmp,newinpInd;

int tab[512][512],values[550001],tab1[512][512],tab2[512][512],tab3[512][512],tab4[512][512],tab5[512][512]; 

int (*arrayp1)[512];

char inp[500005];
char newinp[500005];

void printOut(int ptab[][512]){
	int ii,jj;
	for(ii=n-1;ii>=0;ii--){
		for(jj=0;jj<m;jj++){
			if(ptab[ii][jj]==-1){
				printf(".");
			}
			else{
				printf("%c",values[ptab[ii][jj]]);
			//	ptab[ii][jj] == -1 ? printf(".") : printf("%d",ptab[ii][jj]);
			}
		}
		printf("\n");
	}
}

bool equalTabs(int inp[][512],int out[][512]){
	int ii,jj;
	for(jj = 0; jj < m ; jj++)
		for(ii = n-1;ii>=0;ii--)
			if(inp[ii][jj]!=out[ii][jj])
				return false;
		
	return true;
}


void simulateStep(int inp[][512],int out[][512],char step){
	int ii,jj,act;
	if(step=='G'){
		for(jj = 0; jj < m ; jj++){
			act = n-1;
			for(ii = n-1;ii>=0;ii--){
				if(inp[ii][jj] != -1){
					out[act--][jj] = inp[ii][jj];
				}
			}
			for(ii = act;ii>=0;ii--){
					out[ii][jj] = -1;
			}
		}
	}
	else if(step=='D'){
		for(jj = 0; jj < m ; jj++){
			act = 0;
			for(ii = 0;ii<n;ii++){
				if(inp[ii][jj] != -1){
					out[act++][jj] = inp[ii][jj];
				}
			}
			for(ii = act;ii<n;ii++){
					out[ii][jj] = -1;
			}
		}
	}
	else if(step=='L'){
		for(ii = 0; ii < n ; ii++){
			act = 0;
			for(jj = 0;jj<m;jj++){
				if(inp[ii][jj] != -1){
					out[ii][act++] = inp[ii][jj];
				}
			}
			for(jj = act;jj<m;jj++){
					out[ii][jj] = -1;
			}
		}
	}
	else if(step=='P'){
		for(ii = 0; ii < n ; ii++){
			act = m-1;
			for(jj = m-1;jj>=0;jj--){
				if(inp[ii][jj] != -1){
					out[ii][act--] = inp[ii][jj];
				}
			}
			for(jj = act;jj>=0;jj--){
					out[ii][jj] = -1;
			}
		}
	}
	else if(step=='.'){
		for(ii = 0; ii < n ; ii++){
			for(jj = 0;jj<m;jj++){
					out[ii][jj] = inp[ii][jj];
			}
		}
	}
}

int whereami1x[550005],
	whereami1y[550005],
	whereami2x[550005],
	whereami2y[550005],
	currentpermtab[550005];

int optAlgo(){
	int ii,jj,permutationStep=0,currentperm=0,iii=0,jjj=0,myval=0,permmod=0,indx=0;
//	printf("newinpInd %d\n",newinpInd);
	if(newinpInd<=8){
		for(i=0;i<=newinpInd;i++){
			if(i==0){
				simulateStep(tab,tab1,newinp[i]);
				arrayp1 = tab1;
			}
			else if(i%2){
				simulateStep(tab1,tab2,newinp[i]);
				arrayp1 = tab2;
			}
			else{
				simulateStep(tab2,tab1,newinp[i]);
				arrayp1 = tab1;
			}
		}
//		simulateStep(arrayp1,tab4,'.');
		return 1;
	}
//	printf("Execute optAlgo\n");
	simulateStep(tab,tab1,newinp[0]);
	simulateStep(tab1,tab4,newinp[1]);
	// simulate 4 steps:
	simulateStep(tab4,tab1,newinp[2]);
	simulateStep(tab1,tab2,newinp[3]);
	simulateStep(tab2,tab1,newinp[4]);
	simulateStep(tab1,tab2,newinp[5]);
		//tab2 vs tab4
	
	for(ii=0;ii<n;ii++){
		for(jj=0;jj<m;jj++){
			tab1[ii][jj]=0; // nie odwiedzone
			if(tab4[ii][jj] >= 0 && tab4[ii][jj] < 250005 ){
				whereami1x[tab4[ii][jj]]=ii;
				whereami1y[tab4[ii][jj]]=jj;
				
				whereami2x[tab2[ii][jj]]=ii;
				whereami2y[tab2[ii][jj]]=jj;
			}
		}
	}
	// wyznacz cykle permutacji
	permutationStep = (newinpInd - 1) /4;
	
	for(ii=0;ii<n;ii++){
		for(jj=0;jj<m;jj++){
			
			if(tab1[ii][jj]==0 && tab4[ii][jj]!=-1){
				currentperm=0;
				iii=ii;
				jjj=jj;
				while(tab1[iii][jjj]==0){
					currentpermtab[currentperm]=tab4[iii][jjj];
					tab1[iii][jjj]=1;
					iii=whereami2x[currentpermtab[currentperm]];
					jjj=whereami2y[currentpermtab[currentperm]];
					currentperm++;
				}
				// przemianuj
				iii=ii;
				jjj=jj;
				permmod = permutationStep % currentperm;
				
		//		printf("CP %d PS %d: ",currentperm,permutationStep);
	//			for(int iiii=0;iiii<currentperm;iiii++){
	//				printf("%d ",currentpermtab[iiii]);
	//			}
	//			printf("\n");
				
				indx = 0;
				while(tab1[iii][jjj]==1){
	//				printf("B %d ",tab4[iii][jjj]);
					tab1[iii][jjj]=2;
					
	//				printf("(%d %d %d = %d) ",indx,permutationStep,currentperm,(indx+permutationStep)%currentperm);
					// najmadrzejsza linijka w kodzie
				//	tab2[iii][jjj]=currentpermtab[(indx-(permutationStep%currentperm)+currentperm)%currentperm];
				    tab4[iii][jjj]=currentpermtab[(indx-permmod+currentperm)%currentperm];
				    
	//				printf("A %d \n",tab4[iii][jjj]);
					
					iii=whereami2x[currentpermtab[indx]];
					jjj=whereami2y[currentpermtab[indx]];
				    
					indx++;
				}
			}
		}
	}
		simulateStep(tab4,tab2,'.');
//	printf("OPTALG:\n");
//	printOut(tab4);
//	printOut(tab2);
	arrayp1 = tab2;
	// dorob koniec
	
//		printf("SS4aaaaaaaa: %d %d\n",permutationStep*4+2, newinpInd);
		
		
	for(int xi=permutationStep*4+2;xi<=newinpInd;xi++){
		
	  //	    printf("SS4111111: %d [[[[[ %c ]]]]]\n",xi,newinp[xi]);
	  	    
			if(xi%2==0){
	  //	    	printf("SS  1 \n");
				simulateStep(tab2,tab1,newinp[xi]);
				arrayp1 = tab1;
			}
			else{
	  //	    	printf("SS  2 \n");
				simulateStep(tab1,tab2,newinp[xi]);
				arrayp1 = tab2;
			}
//			printOut(arrayp1);
		}
//		printf("SS4:\n");
//		simulateStep(arrayp1,tab4,'.');
		
		
//	printf("OPTALG XXXXXXXXXX:\n");
//	printOut(tab2);
//	printf("OPTALG YYYYYYYYYYYY:\n");
//	printOut(arrayp1);
	
	return 0;
}


int algo(){
	newinp[0]=inp[0];
	newinpInd=0;
	//
	
	for(i = 1 ; i < k ; i++){
		if(newinpInd == 0){
			if(((newinp[0] == 'G' || newinp[0]=='D') && (inp[i] == 'G' || inp[i]=='D'))
			||	((newinp[0] == 'L' || newinp[0]=='P') && (inp[i] == 'L' || inp[i]=='P'))){
				newinp[0]=inp[i];
			}
			else{ // dostalismy cos w innej plaszczyznie
				newinp[++newinpInd]=inp[i];
			}
		}
		else{
			if(newinp[newinpInd] == inp[i]){ // zdublowanie - nic nie rob
			}
			else if((newinp[newinpInd] == 'G' && inp[i]=='D')||
			(newinp[newinpInd] == 'D' && inp[i]=='G')||
			(newinp[newinpInd] == 'L' && inp[i]=='P')||
			(newinp[newinpInd] == 'P' && inp[i]=='L')){
				// dostalismy oposite - mozna odwrocic
				newinpInd--;
				if(newinpInd==0){ // ale zawsze do co najmniej 2
					newinp[++newinpInd]=inp[i];
				}
			}
			else{ // dostalismy cos w innej plaszczyznie
				if(newinp[newinpInd-1]==inp[i]){// nic nie rob
				}
				else{
				newinp[++newinpInd]=inp[i];
				}
			}	
		}
	}
//	newinp[newinpInd]='G';
	
	
	optAlgo();
	simulateStep(arrayp1,tab4,'.');
	printOut(arrayp1);
	/*
	for(i=0;i<k;i++){
		if(i==0){
			simulateStep(tab,tab1,inp[i]);
			arrayp1 = tab1;
		}
		else if(i%2){
			simulateStep(tab1,tab2,inp[i]);
			arrayp1 = tab2;
		}
		else{
			simulateStep(tab2,tab1,inp[i]);
			arrayp1 = tab1;
		}
	}	
	
	
	if(!equalTabs(tab4,arrayp1)){
		/////////////////////////////
		newinp[newinpInd+1]='\n';
		printf("%s\n",inp,newinp);
		
		for(int i=0;i<=newinpInd;i++){
		printf("%c",newinp[i]);
		}
		printf("\n-----BRUT ------\n");
		////////////////////////
			printOut(tab3);
			printf("-----OPT--------------\n");
			printOut(tab4);
			printf("KURWA !!");
			return 1;
	}
	*/
	
	return 0;
}

int generateRandom(){
	printf("=======================\n");
	int ii,jj,randomN;
	n=(rand()%10)+1;
	m=(rand()%10)+1;
	;k=500000;
	cnt=0;
	for(ii=0;ii<n;ii++){
		for(jj=0;jj<m;jj++){
			randomN=rand()%3;
			if(randomN==0){
				tab[ii][jj]=-1;
			}
			else{
				if(randomN%2==1){
					values[cnt]='B';
				}else{
					values[cnt]='C';
				}
				tab[ii][jj]=cnt++;
			}
		}
	}
	for(ii=0;ii<k;ii++){
		randomN=rand()%4;
		if(randomN==0){
			inp[ii]='G';
		}
		if(randomN==1){
			inp[ii]='L';
		}
		if(randomN==2){
			inp[ii]='P';
		}
		if(randomN==3){
			inp[ii]='D';
		}
	}
	/*
	inp[0]='D';
	inp[1]='P';
	inp[2]='G';
	inp[3]='L';
	inp[0+4]='D';
	inp[1+4]='P';
	inp[2+4]='G';
	inp[3+4]='L';
	inp[0+8]='D';
	inp[1+8]='P';
	inp[2+8]='G';
	inp[3+8]='L';
	inp[0+12]='D';
	inp[1+12]='P';
	inp[2+12]='G';
	inp[3+12]='L';
	inp[0+16]='D';
	inp[1+16]='P';
	inp[2+16]='G';
	inp[3+16]='L';
	*/
	/*
	inp[0]='P';
	inp[1]='G';
	inp[2]='L';
	inp[3]='D';
	inp[0+4]='P';
	inp[1+4]='G';
	inp[2+4]='L';
	inp[3+4]='D';
	inp[0+8]='P';
	inp[1+8]='G';
	inp[2+8]='L';
	inp[3+8]='D';
	inp[0+12]='P';
	inp[1+12]='G';
	inp[2+12]='L';
	inp[3+12]='D';
	inp[0+16]='P';
	inp[1+16]='G';
	inp[2+16]='L';
	inp[3+16]='D';
	*/
	
}

int main(){
	
	scanf("%d%d",&n,&m);
	cnt=0;
	for(i=n-1;i>=0;i--){
		scanf("%s",inp);
		for(j=0;j<m;j++){
			if(inp[j] =='.'){
				tab[i][j] = -1;
			}
			else{
				tab[i][j]=cnt;
				values[cnt++]=inp[j];
			}
		}
	}
	//
	scanf("%d",&k);
	scanf("%s",inp);
	
	algo();
	
	/*
	int res = 0;
	while(res==0){
		generateRandom();
		res = algo();
	}
	*/
	

}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 1ms
memory: 19908kb

input:

20 20
.BC.BC.....B.B......
.CC.....BBBC.C....C.
.....BB..B.BBC...CB.
.B.........C.BC..C..
.C.CB.B....B.C...CB.
C..C.BBB...CB.B..CC.
.B.CBCB...CC.B....C.
......B....B.C.B.CC.
C.B..CC......C....B.
.....BC......BC..CC.
.BC..CC....B.....C..
.....C.....BBBC...C.
.C.........BBBB..BCC
...CBBB....B.B....B.
...

output:

CCCBBCBCCBCCBBBCCBB.
CCBCCBCBBCBBCCC.....
BBCBCBBCBBBB........
CCCBBCCBBCCC........
CCBBCBBCBBBC........
BBCBCCBBBCBC........
BBBCBBB.............
CCCBCCC.............
BBCBBBC.............
BBCCBCC.............
CBBBBB..............
BCCCB...............
BCCCB...............
CCCB................
BBC......

result:

ok 20 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 17956kb

input:

5 13
.CCBCB...BC.C
CBBCCC.C.BBBC
BCCBBB.C.CCB.
CB.C.C...CBC.
B.BCCC.C.B.BB
35
GGGPLDPGPLDLPPPDPGLDLPGLDDPDDPGLDPP

output:

..........CBB
....CBCCCCBBB
..CCCCCCCBCCB
..CBBBBBCCBBC
..CCBBCBCBCCB

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 11744kb

input:

1 2
CC
5
LPLLD

output:

CC

result:

ok single line: 'CC'

Test #4:

score: 0
Accepted
time: 4ms
memory: 11812kb

input:

5 6
CBCCC.
C..BBB
.B..B.
BB..B.
B.CCC.
21
DGDDDDGDDDDGGDDDPDDLL

output:

C.....
CB....
CBCB..
BBCBB.
BBCCCB

result:

ok 5 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 9784kb

input:

12 20
............B.......
..C....C............
B.B..........C...C..
C...B.......BB.C..B.
........B....C......
...........C........
................B...
....C.C...C..C...CC.
.......BB...C.......
........B...........
....................
.C..BB..B...........
98
GGDGGGGDGDDDDDGDGGGDDGGDGGGDDGDGDGGGDGG...

output:

....CCBCCCBBBCCBBCCC
...........CBCCBBCBB
................CBBB
..................BC
....................
....................
....................
....................
....................
....................
....................
....................

result:

ok 12 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 11748kb

input:

1 19
..C.......C.C......
40
GDDDGGDGDGDDDGDGDDDDDGDGDDDGGGGGGDLDDLDD

output:

CCC................

result:

ok single line: 'CCC................'

Test #7:

score: 0
Accepted
time: 0ms
memory: 11748kb

input:

20 20
...B..BB.C......CBC.
.....BC...B.........
.B......C.BBB..B.C.C
..B.CC...C.......C.B
.BBB..B......B..C.C.
....C..C.B..B.B.C...
B.C.C....B.B..CC..CC
..CBB...C.CBBBB.B...
B..B.....B.BCBB....C
........BB...C......
...B...C..BC.......C
.C.....C.B.C........
B...B...CC..C.BCB.C.
.B..C..CC....CBC....
...

output:

BCBBCBBBCCBCCCCCBBCB
BBCBBBBBCCCBCBBBBBCB
BCCBCCCCBBBBBBBBBBCC
BCBBBCBBCBCCCBBBCCCC
CBBBBBCCCCCBBCBCCC..
BCBCBBCCCCBBCB......
BBBCBCCCCC..........
CBCCCCC.............
BBC.................
....................
....................
....................
....................
....................
.........

result:

ok 20 lines

Test #8:

score: 0
Accepted
time: 3ms
memory: 9804kb

input:

13 19
..BC.B....CBBC.BC..
.C..BC.CB..B..B.BB.
C.B.B...B..B.B..CC.
.C.BC.CBB.CC...CBBC
.CB.B.B.....C.C.BB.
CC....CC..BB.....C.
CCC.C..B.B.CBBCCCB.
CB.C.B.C...BC..BBB.
.BB..BC.B.....CC..B
BB.CBBB.BBBC.CB.CCC
..C.CCBB.C.B.CC..BC
..CBC.......BBC..B.
BB......B...B.C...C
100
GDGGGDDGDDGDDGGGGDDDGGDDGDGGGG...

output:

CCBCBBCCBBCBBCBBCBC
CCBBBCBBBBCBCBCCBCB
CCBCCBCCBCBBBBCCCBC
CCCCBBCBB.BCCCCBBBC
BCBBCBBCB..BBCBCBCC
BBC.BCBBB..CBBC.CB.
.BC.C......B..C.BB.
.B..C......C..C.CC.
.B.........B.....B.
.................B.
...................
...................
...................

result:

ok 13 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 20004kb

input:

13 16
C..B..B...CBB.CC
...B............
................
................
BBCCCCBBCBCBCCCC
...BB.CCC...CCCB
................
........B.......
..............B.
................
BB.CB.B....C.CCC
BB.CBCCCBCBBBBCB
B..........BB..C
100
PLLLDGLGPGPPDDPLDDGPGPDLDLGGLPDLGPDDDGPLGLLDPLDPDLLGPPDPLPPPDLLLGPDLG...

output:

CCCCBCBBBCBBCCCC
.CBCCCBCCCCCBCBB
.......BBBBCBBCC
.......CBCBBBBBB
........BCCBCBBC
............CBBB
...............C
...............C
...............B
................
................
................
................

result:

ok 13 lines

Subtask #2:

score: 1
Accepted

Test #10:

score: 1
Accepted
time: 0ms
memory: 19968kb

input:

100 100
.C..BB.....BBB.B.C.BC.B..CCC.CB.B.B..C..C.BC...CBBC.B..BC.C.C...BCC.BCCB..CB.CCBC......C.CB.....CCCB
.B.B.C.CC.B...C....CCCC.C.BCCCB..BB.B...C.B...B.C..C....C.CBB.......C.C...B..BBB..C.B.CC....B...BCCB
CB.BCCBB...CC....B.BCB....B.C....BC....BB.BC..C.BBBB....C..CCCC...C.BBCC..BB.C..C.CBCBB..B...

output:

CBCCCBBCBCCCBCBCBCCBBBCCCCBCBCCCBBCBCCCCBCBCCCCCCCBBCCBBCCBCCCBCCBCCBCBBCCBCBBCCBCBBCBCCCBBBCCBBCBBB
CCCCBBBCCBBCCCCCCCCBBBBBCBBCBBBBBCBBBCBCCBCCCBBBCCBBBCBBCBCBBCCCCCBCCBCCCBBBBCCBCBBBCCBBCCBBBCCCBCCB
CBCCBBBCBCCCCCBCBCCBBBBCCCCBCCCCCBBBBBBBBBBBBBBBBBBCBBBBBBBBBBCCCCBCCBBCCBBBBCCCCCBBBCBCBBBCCCBBCB...

result:

ok 100 lines

Test #11:

score: 0
Accepted
time: 2ms
memory: 18060kb

input:

74 32
.C....C...C.B...B.C..B.CCCCB.B.C
BB...C.BC.....B.B.......C.......
CBB....BBCCCBCCBCCB.BBC.CBBC.C.C
BBCBBBCBBCCB.BBCBCBB.CC.CCCCBCCB
CCBCCBBBBBCCCCBBBBCCBBCCCBCBBBB.
CC...CC.CC.B.......B......C..B.C
.CBBCBBBBCC.BB..B.CB.BCCBCCC.BCC
.B...C..........C.....C......B..
CBBBBBB.CCCB.CCBB..C..BBBBCBCB...

output:

................................
................................
................................
................................
...............................B
...............................C
...............................B
.............................BBC
...........................CBBBB
......

result:

ok 74 lines

Test #12:

score: 0
Accepted
time: 1ms
memory: 18132kb

input:

87 10
.BB.CBB...
.CC.BCBBC.
CBBCBCCCB.
BBB.BCB...
..C.CCB..B
.BC.B.B...
.BB.B.CCB.
..C.BCC...
BBC.BB.B..
.BC.BCC...
.BB.BCB.C.
.CC.BC.BC.
.CB.CBC.B.
CCC.B.B.B.
CBB.C.B.C.
.C..BCCB..
.C..BBC...
.CB.B.C...
.CC.BB.CCC
.BB.B...C.
.CC.B.BCB.
C.C..CBBC.
.BC.BBC.B.
.BB.CBCCB.
..C.CC.C..
.BC.BBC.C.
.CB.BCC....

output:

..........
..........
..........
..........
.........B
.........C
.........B
........CC
........BC
........CC
........BB
........CC
........BB
........CB
........BC
........CB
.......CBB
.......CBB
......BCCC
......CBCB
......BCCC
......BBCC
......BBCB
......BCBC
......BBBC
.....BCBBB
.....BBBBB
......

result:

ok 87 lines

Test #13:

score: 0
Accepted
time: 0ms
memory: 18084kb

input:

81 16
..B.............
..CC.B....CC....
CC.CCBB.B......C
BBCB............
CBB.BBC.........
..C.B.C...BB....
.CBCCC......CCB.
.C.BBB....C.....
..B..C....B....C
CCC..CC...C....C
C..CB.B...B..C.B
C.CBCB.C......C.
BC.C.CB...CC..C.
C.BC.C....CC....
B.BC.BB...B...BC
...C.B.....C....
...B.C....CB..B.
..BB....

output:

CCBBBBCCCCBBCBC.
CCCCCBCBCBBCCBB.
CBCBBCCCCCCCCBC.
BCBCCCBCCCCCCBB.
CBCBBCBBCBCCCBC.
CCCBCBCBCBCBBCC.
CCCCBCBCBCBBB...
BBCBCBBBCCCCC...
CBBBCCCCCBBCC...
BBCCCBCCBBBB....
BCCCBCCBBBBB....
CCBCBCBCBBCC....
BCBCCBCCBBBB....
BBCCBCBBBCBB....
BCCBCCCCBCBC....
BCCCCCCCCCBC....
BCBCBCCBBBBC....
BCBBCCCCBCB...

result:

ok 81 lines

Test #14:

score: 0
Accepted
time: 1ms
memory: 18096kb

input:

91 22
..............CC......
......................
............C.........
.....C.....B..........
.......C.....C........
.....................B
.................B..C.
..........C.C.........
....B.................
......B........C......
......................
......................
.................B...

output:

CCCB..................
CBCB..................
CBCB..................
CCB...................
BCB...................
BCB...................
BCB...................
BCB...................
BBC...................
BB....................
BC....................
CC....................
BB....................
C...

result:

ok 91 lines

Test #15:

score: 0
Accepted
time: 1ms
memory: 17960kb

input:

18 73
....BCCC......C.CB..CB.....C...C...........B..BCC.CC.BC.....C..........B.
.C.C....B.B..B...BC....BCBC......C.....C..C....B.C....C.B..BCC...C.B....B
.B.......C............C....C....B.....C....C..C..................B.......
.......B...C.B.......BB.BC........B..CB...CB.C......B.....BC.C......B.B....

output:

BCCBBCBCBCCBCCCBCBCCBBBBBC...............................................
CCBBBCCBCBBBCBBCCBCBBBCB.................................................
BBCCCBCCCBBCCBBCCBCCCCCB.................................................
CCCCCCCBCCBCBBCBCBBCB....................................................
CBBB...

result:

ok 18 lines

Test #16:

score: 0
Accepted
time: 0ms
memory: 18140kb

input:

70 4
C...
....
...C
..B.
B..B
....
..C.
C...
....
....
....
....
....
....
....
....
....
C...
....
....
..B.
..C.
B.B.
...B
.C..
....
....
....
....
....
....
....
....
....
CB..
....
....
....
....
....
....
...B
..C.
...C
....
....
....
....
....
....
....
....
....
..B.
.C..
....
C...
B...
..B.
...

output:

CCCB
CBBB
BBCC
CBCC
.CBC
.BBB
..CB
..CB
..BC
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
....
...

result:

ok 70 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 9904kb

input:

77 40
BB...CCB.C..B..BB.B.B...CB....CCB.....BB
....C.....B..BBBCC...BB.C.C..BC.B.B.CB.B
.B.CCBC.C..C.C...BC..C.B..CCBC.CB.C.CBB.
C.C.BCC....C..C...BC...BBB.C.B.B.CBBBCB.
.C.C..BB.B.C..B.......CC.B.B.CC....C...C
CBCB.BBB.C.B...B....BCBBB.......BBC..C..
.BCBCCC...CB.C..B.C.CB..BC....B..BC.CC..
B..BCB....

output:

......................BBCCBCBBBBBCBCCBBB
......................CBBBBCCBBCCBCBBCBB
..................BCCBCCCCBCCBCCBCCBCCBB
...................CCBCCCCBCBBBCBBCBBBCB
.........................CCBBBCBCCBBCCCC
.....................CBCBBBBCBBBCBBBBBCC
....................BCBCCCCBCBCCBBCBBCCC
................

result:

ok 77 lines

Test #18:

score: 0
Accepted
time: 1ms
memory: 19988kb

input:

71 77
...........................C.................................................
CB.CB.CB.CB.BCCB..CC..BC..B.......B..B.CBBB.C..B.C..CB.B..B...B.....CC..B.BB.
CCC.CC.BBCB.BCCB.CBCBCCCCCCCB.C.C.CC...BCBCCCCCCCBCBBBCCCC..C.C.B.CCCCC.CCBBC
CCCBBBBBCBBCCCC.BCBC..CB..CB.BCCCCCCCBBCBB.BBCC.CCBBBCCB.BBB...

output:

CCCCCCBBBCCBCCBCBCBBCBCBBBBCCCCCCCBBCCBBCCBCBCCBBCCCCBCCBBCBBCCBBBBCBBBCCBBCC
.BBBCCCBBCCBBBCCCCBCBCBCBCBBCBCCCBCCBCBCBCCBBCCBBBCCCCBBBBBBCBCBCCBCBBBCBBBBB
.BBCBBBBBBCCBCCBCBBCBBBCBBBCCCCCCCBBBCBBBBCCCBBBBBCBBBBCBBCBCCCBBBCBCCCCBBCBC
.....CBCBBCBCBCBBBBCCCCCCBBBCBCCBCBCBCBBBCBCBCCCBCCCCBBBCBBBBCBCCB...

result:

ok 71 lines

Subtask #3:

score: 1
Accepted

Test #19:

score: 1
Accepted
time: 39ms
memory: 20312kb

input:

500 500
BCCC..CBBBC.CC.CC..B.C.C..B...CCCC...C...CCBBC.C..BBB.B...BCCBBB..B.CBC.BCB..BB..B.CC...BC.B..BB.C.BBBCB.B..CCCBC.C.BBB..BC.CCBC.B.BC.BBB..CB..C.CC.BCC.......C..C...CCBB...B.C.C.B.C..C...CCC..CB.BBCCC...CCBB...C....CC..B.CB......C.B.......C..BB.....C.BBB....B........C.....B...CCB.C.B..CCCBCC...

output:

BBCBCCCBBCCBBBCBBBBCCCCCBCBBBBCCCBBBBBCBBBBCCCCBBCBBBCBCBBCCBBCCBBCBCBBBCBBBBCCCCBCBBCBCBBBBBCCBCBCBCBBCBCCCBCCBBBCBCCCBBCCCCCCBCBCBBBBCBBBCBCCCCCCBCCBCCCCBCCBCBBBCBBBBCBBBBBBCCCBCCBCBBCBBCCCBBBBCCBCBBCBCCBCCCCCBCBBCBCCCCCBCCBCCCBCCCCCBCCBCBCBBBBCCBBBBCBCCCCCCBCBBCCBBCBCBBCCCBBBBBBBCCCCCCCBBBCBBBCBC...

result:

ok 500 lines

Test #20:

score: 0
Accepted
time: 2ms
memory: 18744kb

input:

394 74
C.C.B.B....C...B..C..B.CCC...B..BB..BB.BB.C.BC..B..BBB......CB.CB..BBC.B.C
C.B..BB..CC....BC........C....B.CB.....B..C.C.B.BBB..B.....BBB.B...BBC...B
...CC.C....CB..B...BCB..BC..BB...C......C.B.....B.B.BBC...BC.B.BB....B.B.C
..CCB.B....B.C.B.CC.C...C...BCB..B....CCC.C.CC..C...CBBB...B.BC.C..B...

output:

BCBBCCCCCBBCBBBCBCBCBBCBBCCCBBBBBCCCCBBBCCBBBCCCCCBBCBCBCCCCCCBCCBBCBCBBCB
CBCBCBBBBBCCCBBBBBBBCCCBCBBCCBCBBCCBBBBBBBBBBBBBBBCCBBBBCCBCCBCCCCCBCBCBBC
CBCCCCBBCBCCCCCCCCCBBBCBCCCBCCBBCBBCBCBBCCCCBCCBBBCBCBBCCCBBBBBBBBBBCBCBBB
CCCBBBCBBBBCCBCCBCCCCCCCCCBCCCBBCCBCBBCCBBBBCCCCCCCCCBBCCCCBCCBCBCCCCCBBCC
...

result:

ok 394 lines

Test #21:

score: 0
Accepted
time: 1ms
memory: 20000kb

input:

14 445
BB.B.B.BBBCB.CB.CCB.BCCBBC.BCB.CBCCCBBBBBB.B.BB.BCBCCCBBBC.CCB.CBB.CCBBBCBBCBCCCB.B.B.BCBBBCBBBCBCC.CBBCBB..CBBCBBCBBBCBCBB.CBB.CBBBCBBBCCBB.CBCBCCBCCBCBCCBCBB.BCC.C.BBC.CBCCCC.CBCCCBBCBCCBCBBBCBBCCBBBCC.BC..CCBCBB.CBCCBBBBCCC.BCBCCBBBCB.BBB.CCCBBCB.CBCCCCBCC.BCB.BCCBBBCB.CCC..CCCB.CCBBBBCBBB...

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 14 lines

Test #22:

score: 0
Accepted
time: 2ms
memory: 18532kb

input:

286 79
CBCBCBCBBBCBBBCBBBCBCCCBCCBCCBCBCBBBBCBBCCCBBBBCBBCBCBBCBCCBBCBBCBCBBCBCBCBCCBC
.BB.C.BCBC.B..BCCBB..B.B.CBCC.BCCB.CBCCBC.BB.BC..CCB.C..BB..BC...B..CCBB..C...C
.......................C......................................................B
...C...B..CBBCB.B.C.BB.CB...BCCBBC.B...C.B.C..C.C.BB....

output:

...............................................................................
..............................................................................B
..............................................................................C
...............................................................

result:

ok 286 lines

Test #23:

score: 0
Accepted
time: 1ms
memory: 19944kb

input:

249 116
CCC.BBCCBCBCCBBCCBBCBBBBB.BCCBCCCCCBCBBBBCBCCCBBCCBBBBCCBCBCCBCBCCBBCCCBBBBCBCCCCBCBCBCBBC.C.BBCBCBBCCBBCCCBCCBCB.CC
BCCCCCBBBCCBBBCBBBBBCBBCCBBBCBCBCC.CBBBBBBBCCCBCBCCBBBBB.CCCBC.CBBCCBCC.BCCBBBCBCCCCBBBBCBBCCC.CCBCCCCCBBCCBBCBCCCBB
BCCBBCBBCCBCCBCCBBBCBBBCBCCB.BCCBCBCCBCCCCBBCCCBBBBBCBCBCC...

output:

....................................................................................................................
....................................................................................................................
.....................................................................

result:

ok 249 lines

Test #24:

score: 0
Accepted
time: 1ms
memory: 19972kb

input:

170 394
.B.B...........B..CB.........................C..........C.....C...C.C.....................B.C.....................C..C.......B.C...................................B..B...C....C.........B......C..BB.......C......CB.....C........................C...............C....C......B.C.C........B..........

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 170 lines

Test #25:

score: 0
Accepted
time: 0ms
memory: 10456kb

input:

368 219
BBC..BCCCCBCCBBBCB.CBCCBCCBBCB.BCBCC..BCBCCCBCCCBC.CCBCCCBCBB.BBC.CB..CBCCCBCCBCCCCCBCCBCBBCCCCCBCCCBBBBC.BCBCBCCBCCC.CBBCCBBC..BBB..CCCBBCC.BBCBBB.CCCCC.C.C.CB.CBCB..CCBBBB.CCCCBBCCBBCCC.B.BBCBCCB.BCBCCCBBCCBCBCCCBC.BC
CCBBB..CCCCBBBBB.CCCCBCBBBBBBCBCCC..B.BCC.CCBBBBB.BBCCCB.CCCC.BBC..CCBCC...

output:

BBCBBBCCCCBCCBBBCBCCBCCBCCBBCBBBCBCCBCBCBCCCBCCCBCBCCBCCCBCBBBBBCCCBCBCBCCCBCCBCCCCCBCCBCBBCCCCCBCCCBBBBCBBCBCBCCBCCCCCBBCCBBCBBBBBBBCCCBBCCBBBCBBBCCCCCCBCCCBCBCCBCBCBCCBBBBBCCCCBBCCBBCCCCBBBBCBCCBBBCBCCCBBCCBCBCCCBCCBC
CCBBBBBCCCCBBBBBBCBCCBCBBBBBBCBCCCBBBBBCCCCCBBBBBBBBCCCBCCCCCBBBCBBCCBCCCBBBCCCB...

result:

ok 368 lines

Test #26:

score: 0
Accepted
time: 7ms
memory: 10368kb

input:

319 225
BBB.B...............B..B...CCBCB.B..C.CB..C.BB.CC...C..CC.CBB....C.....BC.C.CBC.B.CBC.B.BB.B..B..C.C..C.BCBCB..B.C.CBCCCB...BB.B..CB.C...B.CBC..B...CC....C.B...C....B.B..C.C......BBB......C.B.C..C.....BBBB..B.CC......BBC.CCB.
BB.B.BC...B..B.B.BCC..BB.C...BC..B.C.CCB.C..B.CB..B...BCB.B.B....B...

output:

BBBBBBCBBBBCCBBBCBCCBBBBBCBCCBCBCBCCCCCBBCCBBBCCCBBCCBBCCBCBBCBBCCCCCCBBCBCBCBCCBCCBCCBBBBBBBCBBCCCCBCCBBCBCBBBBCCCCBCCCBBCBBBCBCCCBCCCCCBBCBCCBBCBCCCBCCCCCBCBBCCCCCBBBBCCBCCBCBBCBBBBBCCBCCBBCCCBCBBCCBBBBBCCBBCCBBBBBBBBCBCCBC
BBCBCCBCBBBBBCCCBBBCBCBBBBBBBBCBBBCCBCCBCBCBBCCBCCBCCBBCBCBBBBBCCBCCCBCBBC...

result:

ok 319 lines

Test #27:

score: 0
Accepted
time: 4ms
memory: 18728kb

input:

379 328
.CBBB.B.C...BCBC.CBB.BCCC...C..BCBB.C.CB...CCCC.CCC..BBCC...CC....C.B..C......C.C.C..C..B.C...CBBCC.C.C.BCBC...BC...BCBB...C..B..BCB.BB..C...CC...CBBCC..BBB...BBBB..BBB.BC.BB.C...CBB..BCC.B..BB.B...CC...CB.BCCC.C.BC..BB.....CBC.C.CB.CC.C...B....BBCBCC.CB.B...C...BBC...BBC......B..C..CBCBB......

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 379 lines

Subtask #4:

score: 1
Accepted

Test #28:

score: 1
Accepted
time: 1ms
memory: 17880kb

input:

10 20
........BC.....B....
....C.C..........B.C
.C..C...B..B.....CB.
.C..B.C.BC.C..B.B..B
....C..........BC..B
.C..B...BB....C.C.CB
.B..B.C........B....
.B..B.........BC...B
.B..B...C..B........
....B...B..C..C..B..
10000
DPLGPDLGPDLGPPPDDLGPDLGPDLGPDLGPPDLGGPDLGPDLGPDLGPPPDLGPDLGPDLGPDLGPGDLDGPDLGP...

output:

BBBCBCBBCCCC........
BBCCCBBBBBBC........
BCBBCCCBBBB.........
CCCCBBB.............
CCBC................
BCB.................
B...................
B...................
B...................
....................

result:

ok 10 lines

Test #29:

score: 0
Accepted
time: 0ms
memory: 17920kb

input:

2 16
....BCB.........
B...........C...
5383
GGGDGDDGDGDDDGDGGGDDGDDDDGGDGGDDDDGDDGGDGDGGDDGDGGDDDGGGDDDDGGGDGGDGGGDGGGGDGGGDGDGDDDGDDGGDDDDGDDGGDGDDGGDDDGDDDGDGDDDDDDDGDDGDDDGDGGDGDGGGDDDGGGGGDGDDGGDGGDDGGGGDGGGGGGGGGGDGGGDDGGDGDDDDGDGDGGDDDGGGGGGGDDDDGGDDDGGDGGGGGDGGDGDGGGDDGGGGDGDDDDGDDDDDGGGDGGDG...

output:

................
...........BBCBC

result:

ok 2 lines

Test #30:

score: 0
Accepted
time: 1ms
memory: 17892kb

input:

16 4
..CC
C..C
CBCB
....
C.B.
....
..BC
.C.B
C..B
BB..
CBC.
CC..
.BBB
BB..
CBBC
....
644
PLLLPPPLLLLLLLPPLPLPLLLLPLLLLPLPLPPLPPPPPPLPLPLPPPLLPPLLLPPLLLLLPLLLLLLPLPLLPLPLLLPPPLLPPLPPPLLLPPLLLPPLLLLLPPPLPPPPPLLPLLLLLPLLPLPPPPLPPPPLLPLPLPLLPPPLLLPPLLPLPLPPLPLLPLLLPPPLPPLLPPLLPLPPLLLLPLPPLLLPLPPLLPPLLPP...

output:

BCCC
BCCC
CBC.
BCC.
BC..
CB..
CB..
BB..
BC..
BB..
BB..
BC..
CB..
....
....
....

result:

ok 16 lines

Test #31:

score: 0
Accepted
time: 1ms
memory: 19988kb

input:

10 8
.BC..C.C
.CB....C
.BB...CB
.CB.C..B
..B....B
..C.C..C
BC....BB
..C....C
C.C....B
.BB....B
7444
DDDGGDDGDGDDGGDDGGGDGGDDGGGDDGDGGGGGDGGDGGGDDGDGGGGDDGGDDGDDDDGDGDGGGDGGGGDGGGDGGGGDGDDDDGDGDGGDGGDDDGDDGDGDDGGDDGGGDDDGGDDGGDDDGGDGGDGDDDDDDGDDGGGGDGGDDDGDGGDDGDDDGDGDGGDGDDGGDGGDGDDDGDDGGDGDDDGGGDGD...

output:

.......C
......CC
......BC
......CC
.....CBC
.....BBB
.....CCC
.....BCB
..BCBBCB
.CBBCBBB

result:

ok 10 lines

Test #32:

score: 0
Accepted
time: 2ms
memory: 19996kb

input:

13 10
..........
..........
..........
..........
.B........
..........
..........
..........
..........
..........
.......C..
..........
C.........
7824
LLLPLLPLLPPLLPPPLLPLLLLPLLLPLPPPLPLPPPLPPLPPLLLLPLPLLLPPPLPLLLLPPPLLLPPLPLLLLLPPLLPLLLPLPLPPPPLLPPPPLPPPPLPLPLPLLPLPPPPPLLLLLPPPPLLPPPPPLPLPLPPLLP...

output:

.........B
.........C
.........C
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........

result:

ok 13 lines

Test #33:

score: 0
Accepted
time: 0ms
memory: 17944kb

input:

8 15
C..BCC.BC.CC.BC
B..BCCBC...B..C
CC.BCCC.B.C.CBC
...CBC.BBC..BCB
BB..CBCC..CCBB.
CCBB.BC.C.BCB.C
..CBC.C..C..B.C
C...C.BB.BCCCBB
6728
GGDDDGGDDGDGGGDGGDGGDDGDGDGDDDDGGGDGGGDDDDGDGDDGGDDDGGDDDDDGDDGDGDGDDGDDGGGGDDGDDDDGGGGGDDDGDGDDGDDDGGDDDDDGDGGDDGGDGDDDDGGGGDGDDGDGDDGDDDGGDGDGGGGGDGDDDDDGDGGGGD...

output:

CCCBBBCBCCBCCBC
BCCBCBBCCCCBCCC
.CCCCCCCCBCCBBC
...BBBCCBBBCBCB
....BCCCCBCBCBB
........BCCBBCB
.............BC
...............

result:

ok 8 lines

Test #34:

score: 0
Accepted
time: 0ms
memory: 19992kb

input:

14 1
.
C
.
.
.
B
.
C
.
.
.
.
.
.
8337
PPPLPPPPLPPPPLPPPPPLPLPPLLPLPPLLPPLPLLPLLLLLLPLPLPPPPLLPPPLPPLLPPLLLPPLPPLPLLLLLPPPPPLLLPPPLPLLLLPLPLPLPLLPPLLLPLPLLPPPLPPLPPPLPPLLPPLLLPPPPLPLPPPPPPPPLLLPLPPLPPLPPPLPPLLPLPPPPPPLLLLLPLLPLPLLPLLLLPLLLLLLPPPLPLPPPPLLPLLLPLPPLLPLPPLLPLLPPLPPPPPLLLPLLPPLLLLPLPLLLLP...

output:

.
.
.
.
.
.
.
.
.
.
.
C
B
C

result:

ok 14 lines

Test #35:

score: 0
Accepted
time: 1ms
memory: 9724kb

input:

10 12
..B...B.C.BB
.B....CC.BC.
BC....C..CB.
....BB...B..
CBCBCB.BCC.C
CC.C.C.C.B..
......BBC..B
.CBB..CB.BB.
.BCC.B...BCC
..CCCBBB.B.C
10000
GDDDDGGDGGGGDDGGDDGGGGDGDGGDGGGGGGDDDGGGGGDGGGDDGDDDGDDDDGGDDDGDGGDDDGDGDGGDDDDDDDDGDGDGGDGGGGDGDDGGDGGGDGGDGDGDGGDGDDDGGDGDGGGGGDGDDDGGGGGDGDDGDDGDDDDGDGDGDG...

output:

............
............
.........B..
.........C..
.B....BC.B..
.CBB.BCB.CBB
.BCC.BCC.BCC
BCBBBCBBCBBB
CCCCCBCBCBBC
CBCCCBBBCBCC

result:

ok 10 lines

Test #36:

score: 0
Accepted
time: 1ms
memory: 17924kb

input:

7 18
.CB....B.BC......B
BCC..B.B......C...
BC.....C.CB.C.CC.B
BBB..BC..CC.B.CB..
C.....BB.CB...BC.C
CCB..B.C..C.C....C
BBB...BB.BC...CC.C
10000
GGGDPLGPGGDLGGPDDLGGPDLGLPDLDGPGGDDPDLLGGPDLDGPDLGLGPPPDLGPGDDPGDPLGGPGDLDGGGGPPLGPGPPGDDDPLGPPPDLGPGDDPLLLGDDPPLGLPDLGPDLDLLGLGPGPGGDLGPDLLLDLDLGPPDLLGPDLG...

output:

..................
..............CBBC
..........CBCBBBBC
.........CCCCBBBBB
......BCCBCBCBCCCB
......CBCCCCCCBCBB
......CBCBBCBBBBCC

result:

ok 7 lines

Subtask #5:

score: 1
Accepted

Test #37:

score: 1
Accepted
time: 3ms
memory: 19976kb

input:

200 200
...C.C.B....CC......CB....C.......B.......BB..B..B.....B..BB..B..C.B.BC..CB............CC....C.C.C..CCCBC..B...B.C...........C..B...B..C..B...........B.B.......CB..B..C.BC..B.C.CB.C..BB..CB.C...C.....
..CC.BBBB....B....BB.C....BBC...BCC....B.....BC....C.B......B.........C.......CC..CCBCB.......

output:

.......................................................................................................................................................................................................C
......................................................................................................

result:

ok 200 lines

Test #38:

score: 0
Accepted
time: 8ms
memory: 18028kb

input:

50 158
CCCCBCCBBCBCB.C.BBCBCBC.BBCBBBBCBCCBBBBBCBBBBCCCBCCCBBBBBBBCBBBBBBBCBBCB.CBBBBCCCCCCCCCCCCCCCCCBCBCBB.BBBBBBCCCCBBBCCCCBBCBCBBC.CCBBCBBCBCB.CBC.CCCBBCBBCBBBBC
................C.B.C........C....B..........C.B.BB....C.................C......BC...................BB.........C........................

output:

..............................................................................................................................................................
................................................................................................................................................

result:

ok 50 lines

Test #39:

score: 0
Accepted
time: 4ms
memory: 19952kb

input:

41 184
CC.B..CC..B.......C.BCBC.....C..CC..B...BC..........B.B.B..B.BB....BCC...BB.....B.C.C.CC.....C.BCC.C...C.CB..CB.B.C.BBCCBBBCCBC.CC...BCC.B.C........BC...B....BCB.....BBB....B.....B...B
CBCCC.CCCCBCC.B.C.CCCCC.B.C..C.CB.B.CC.BC.BBB.CBBC.B.C.BBBC.BBCCCB..BC.C...BCCC.CBC.BCCCCC.C.CC..CBB...CC..B...

output:

....................................................................................................................................................................................CCBB
......................................................................................................................

result:

ok 41 lines

Test #40:

score: 0
Accepted
time: 7ms
memory: 18292kb

input:

200 174
BBBB.BBCBBBBCBCC.B.BC..B..CCB..B.B..BC.BBBCBCBC.B..CCCBBCCC.C....C.CBCCBB.CCCB.BC.BCCCCBBBBC.BCCB.C.B.CCBB.BB.CBCC.CBC.BB.BBCB.BCB..BB..CBCBBBC.CB.BBC.BBCBCBCBBC.C.B.CCCC.BCC
..CCCBCCCBBC...CBCBBCCBBBC..BCBCBBCBCBBCBBCCCCCBCCCBCCC.BCBCBBCCBBBCCB.BBBCCCB.BBBCBCB.BBBCC.C.CCCBBB.BBCCCC.C..BBBC....

output:

BBBBCCCCBBBBCBCCBCCCCCCCCCBBCCBBCBBCBCCCCCCCBCBCBBBCCBBBCCCCBCBBCBBCBCBBBCCBBBBCCBCCCCCCBCCCBCCCCBCCBBBBBBCBCCCBCCCCCCCBBBBCBCBCCBBBCBBCCCBBBCBBBCCCCCBBCBCCBCCCBBBCBBCCCCBBCB
CCBBCBCBCBBBCCBCBCCCBCBBCCCCBBCCBCBCBCBCCBBCCBBCBCBCCBBBBBCCBBCCBBCBBBBCBBCBCBCBBBCBBCBBBCCCCCCCCCCBCBBCCBBCCBCBBCBBCCCBCBCBC...

result:

ok 200 lines

Test #41:

score: 0
Accepted
time: 3ms
memory: 20012kb

input:

133 146
CCB.BCBCCCBBC.BBBBBCBBC.CBBBBCBCCBC.BCB.CCCBBCBCBBC.BCC.CCCCCB.BBCCB.B..CBBCCBCBBBBCCB.CBBCCCBCCBBCCCBBBCCBCBBBCCBCBBBBBBBCCBBC.CBCC.CBBBBB.BCBCBB
CBBBBC.BBCCCBBBCC.CBBBC.BCCBBBCCBCCCBBBCCBBBBC..BCB.CBBCB.BBCCBBBBCCCCB.CCBCBCCCCCBBCCCC.CBCBBCCCC.CCBCBCBBCBBBCBCCBB.BCCBBCCBBBCBBBCCBCBCBCCBCBC...

output:

..............................BBBBCBCBCBBBBBCCBBBBBBBBCBBBCBBBCCBCCCBCBBBBBCBBCBCBBCCCCBCBBBCBCCBBCCBBBBCCCCBBCBBCCCBCCCBCCCBBCBCBBBCCBBCBCCCBBCBB
.........................BBCBBBBCCBBCCCCBCBCCCBCCCCBCCBBCCCBBBCBCBCCCCBCCBBCBBBBCCBCBBBCCCBCBBCCCCBBCCBBCCCCBCBBCCBCBCCBBCCCBCCBBBCBCCCBCBCBBBBBBB
.........

result:

ok 133 lines

Test #42:

score: 0
Accepted
time: 1ms
memory: 18200kb

input:

152 171
....B..C............BC.C..BCC.....C.B......C............CB.B.C.................BC.....C....C..B..............C.C.....C...C..B....B..C..........CBB.......B.CB...C..B.......
......C.B...B.......B.B.C............B.C.C...........CC....C.C...B.C.B.C.............CCC..B..BCC.C.B.B....B.......C.BBCB...

output:

...........................................................................................................................................................................
...................................................................................................................................

result:

ok 152 lines

Test #43:

score: 0
Accepted
time: 3ms
memory: 19968kb

input:

19 144
C..C..C.C.C.CBCB.BBBBB.B...BCCCCBBBCCB...CC.C.CC.CB.BC.C..CCBCBC..CBCBC.C.BCCCBCCBC.BCC.BBB.CBCBCBBCCBB.B..CCBBBCB.BBCCBB.C.BBCBBB.CCCBCBC...CBB
CCC.BC.BCBBBCBB..BCCC.BCCBBC.BCBBCBCCBBBBCC.CCCCBCCB..CBBC.BCBC.CC..CB.CBB.CBBBCBCBBC..CCCCC.BCB.CCCBCB..CCBBBCCBBBC.BCCBCBCCBBBB.BB.BBCCBB.BBC.
B.B...

output:

CCCCBBCBBCBCBBBCBBBBCBBCCBBCBBCCCCCCBCCBBBBCCBCBBBCBCBBBCCBCBCBCCBBCBCCBCBBBBBCBCBCCBCCCCCCCCCBBCBBCCCCCBBBBBCBCCCBCBCBBBCBBCBBBBBBCBBCBBCCBBCCB
CCBCCCBCCCCCBBBCBBCCCCBCCCCBBCCBCCBCCBBCCBCCCCBCBBCBCCBBBCCCBCBBBCBCBCCBBCBCBCCCBBBBCCCBBBCBBBBBBBBCBBBCBBBBCBBBBBCBCBCBBBBCCBBCCCCCBCCCBBBCBBBC
CCBBBBBCCC...

result:

ok 19 lines

Test #44:

score: 0
Accepted
time: 3ms
memory: 9716kb

input:

121 132
C..B...B...C......CB.CBB..B..CBCC...B...CC..BCBC...B...CC..B.B..CC.C...B...CCBBB.C.BCB.BBCBB.....CBB.B..C..B.CB..B.CCBB.CB.CCBBCBB.B
.C.C..B.CB..CCC..CB.B.C.B..CBBB.C...B..CBCC...C..CBCB..CB..BBBB.C.B.B....B.C.C....CBBCB.CBBCB...B..C.C.CCBBCC...B..C.C.B.C..B.CCC..C
...BC...CBB.CBBB...B....CB...

output:

....................................................................................................................................
....................................................................................................................................
.....................................

result:

ok 121 lines

Test #45:

score: 0
Accepted
time: 9ms
memory: 18276kb

input:

191 112
.BCB.BCCCB..CCBC.B....C..BC.CB..B.CBB.C......B.B..C.CC..BC.C...CC.BC..BC..C..CC.C.CBBBCC...CB..B.CC.BB..C...BBC.
.....BB.B...CC.B.....C...C.C.CCBBB.C..BC....CB.B....BB..BC..B..CCCBBC.CB...B..C..CCCB.CCBCBB....CC..BBCB...B.B..
C..BC.BCCB.BCB.BCB..BCB..BB.BC..B..B.BB.CB..BBBC..C..C.BCB.B..BCC....

output:

................................................................................................................
................................................................................................................
.............................................................................

result:

ok 191 lines

Subtask #6:

score: 1
Accepted

Test #46:

score: 1
Accepted
time: 6ms
memory: 20072kb

input:

300 300
BC.CCB.C..C......BC.....BCB..C.BB...CBBCC...BC.BB...B..CBBBB...C.BC....CC.BCCB.CC.B..B.C..BC.....CC.C.B.BCCB.BC..B.B.CB.B.CBB..B....B....BC..BB.B...C.CCB..CBCCB.CC...B.BB.B..B..CC.CCBBC.C.C.B...B.BB.....CCB.CC..BBBCB..CC..CCB.CCB....BC...BCBBCCBCCCBC.BB.....C...CCCB..CB.CBBC.CB..C.C.C.B..C.....

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 300 lines

Test #47:

score: 0
Accepted
time: 8ms
memory: 20000kb

input:

178 181
B.B.BB....C.CCC.......CCC.B...BB.C....C...B.CC..BCC....CC....C.CBBB...BB....CBB.BB.........CB.B....B........C......BB.B.CC..CB.....C..CB.B..CC.C..BCC.C.BBB....CB.........C....B.C.BB
.............................C........................................................C..........................

output:

.....BBBCCBBCBCBBCCBBCBBBCBCBBBBCBBCBBCBCBBCBBBBBBCCBBBCBCBBCBBCBBBCBBBBCBCCBBBBCBBCBCBBCCBCBBCCCCCBBCCCBBCCBCBCBBBCBBBCBBBBCCBCCBBCBCBCBCCCBBCBCBCCCBBCBCCCBCBBBBCCBCCBCCCCCBBBBCCBC
......BCCCCBCBBBCCBBBCCBBBBCCCBBBBBCCBCBBCCCBBCCCBCBCCBCBCCCCBBCCBCCBBBBBBCCCBBBBBCBBCBCCBCCBBCCCBBCBCCBCBBCBCCCBBBBBB...

result:

ok 178 lines

Test #48:

score: 0
Accepted
time: 6ms
memory: 18156kb

input:

102 35
CB.CCC..C..BB..BC.CCB...C.CCCB.CCCC
CBC..CCB..CCC.C.B.BBC.CBB....BC..BC
CC..BB.B..BCC.BCCB.B...CC...CB.BBB.
......CC..BBC..BB.BBB.C.BC.BCC..CCC
CBC.BBB.CCCC..CBC.CB....B....B..CCB
.B.B.BC.BC.CC..CC..CB.CBCCB.CBB..CC
...CCBB.......BCB..C..C.C..B.B.B.BB
.CBC.CCB.......CC..C.CCCC...CB.B.BC
.B.C....

output:

CCCBBCBBCBBBCCBBBBCCCCBCBBCCBBBCCC.
CCCCCCCCBCCBBCBBBBBBCCBCCCCBCBCCCB.
BCCCCBBBBCBCBCCBBBBBBCBCCCCCCCBBCC.
CBCCBCBCCCBBCBCBBBBBCCCBBCBBBBCBCC.
BCCBBCBCCBCBCCBCCCBBCCCCCCBBBCBBCB.
BBBCBBBCCBCBBCBBBCBBBCCCCBBBCBBCCB.
BCBBCBBCBBBBBBCCCBCCCCBBBCBCCBCBBB.
CBCBCBBCCCCCBCCCCCCCCBCCCCBCBBCBB..
CBCBCBCCBBBC...

result:

ok 102 lines

Test #49:

score: 0
Accepted
time: 6ms
memory: 19916kb

input:

290 119
CCC.B...B..BCBBBCCCBCCC.C..CCBBCC....CCCCCBBBCC.CC..C...B.BB.B.B.B..CC.B..C..BBC..B..CCCCB..BC..CC...BBCBC.....CC...C..
B...CC.BBB.BC..C.BB.BBB.C.BC.B...B...BCB.BBBBBBB.B.CB.BC.BCB.C.B....B.....CB.BCC.B.C..C.CB..BBC.B...BBCCB..C...BB......
C.B.BB..C..C.CCC.C..B.C.BC.C.CC.C.....B.BB..CBCCCCCC...

output:

......................................................................................................................B
......................................................................................................................C
...............................................................

result:

ok 290 lines

Test #50:

score: 0
Accepted
time: 4ms
memory: 20380kb

input:

210 246
C.BBB.C..BCCB..BBC.BBCC.CB.B.C.B.BBB.CC.BBCC.B.BBB..BC.BB.CCC..C.BCBCC...B.BC.C.CBBBBCCB.CBCC..B...CBB.B.CBCC..C..C.CCBCBBB.BBCBBCCCB.C.CBCC.BCB.C....B...B.BCCC..CC.BB.CCCB...CBBBC.BBBCC.B.C.CB.CB.C.B.C..C.CBCCBC....CB.CB..CBBBCBB.CBBBB.CC..CB.B.
.CBBBCCBC.BCB..BBCCB.BCC..CC.C......C.CCBBCBB...

output:

BBCCCBBBBCCCCBBBCCCBBBCBCBBCCBCBCBCCCBBBBBBCBBBBCCBBBCCBBCCCBCCBCCCBCBCCBCCCBBBBCBCCCBBBBCBCBCCBBCBCCCBCBCBCCCCCCBCBCCBBCBCCBCBBBCCCCBCCBBBCCBBCBCBCCCCBCBBBBCCBBBCCBCCCCCBBCCBCCBCBC.................................................................
BCBBCBBCBCCCCCBCCBBBBCCCBCCBCBCBBBCCCCBBBCCBCBCBCCBBC...

result:

ok 210 lines

Test #51:

score: 0
Accepted
time: 2ms
memory: 18472kb

input:

289 18
.CB..CBC..C.C..C..
.CC...CCBB....B...
CC...B.B.B...B.BB.
...BC....C........
.BC..BC.....C.BC..
..BB.B.C.B.B.C....
BBBB.CB...BB.B....
..C..C.C......B..B
.......B.BBBB...B.
.B.....C....CC...C
.B.......C.C.CC..B
.BB..B....C.C.C...
.CC.CB....B.B....C
..B..CB...C..B..C.
C........B...B.B..
CB.B...C...

output:

................CC
................BC
................CB
................BC
................BC
...............CCB
...............CCB
...............CCC
...............BCC
...............CBB
...............BBB
...............CCB
...............BBB
...............CBC
...............CBB
..................

result:

ok 289 lines

Test #52:

score: 0
Accepted
time: 1ms
memory: 20000kb

input:

68 98
....BC.C..C......C..B.B.....B.CC...C.C.....C.....BC.CB..B.C..B.BB....CB.B.CBC.C.C.B...C......BC..C
...BBC....B.B..C....B.....C.B.B.C.B.B..CBCC...C.C..CC..BB.BB.C.B...B...CBC.C............B.C....C.B
..C...BB.B.BC..C.C......B.C..B...BBB......B..BC.CC....CC....B...C...B...B.C...B.B.CBB.BBC.B........

output:

CCCBCBBBCBCBBBCBBBBBCCCBCBBBBBCCCBBBCBCCBCCBBBCCBCCCBBBCCBBCCBCBCBBCBBCBCCBCBCBBBBBCCCBBBCBCCCCCBB
BBCCBBCBCBBCBCCCCBCCBCBCBCCCCBCBBCCBBBBCBCBBCCCBCCCBCCBBCCCCBCBBCCCCCCCCCCBCBCBBBBBCBBCCCBBCCBCBCB
CBCBBBCCBCCCBBBBBCBCCCCBBBCCCBCBBBCBBBCCCBCCCCCCBBCBCCCBBCBCBBBBBCCBBCCCCCBBBCBCBBBCCCBBBBCBBBCCBB
BBC...

result:

ok 68 lines

Test #53:

score: 0
Accepted
time: 4ms
memory: 19964kb

input:

292 171
B..CB.......C.....C..CB.....BCC....B.......C..B..C...B.B........B..B..C...C..B.C.B...CC....BB....C....BC.......BC.........B.C...C...B.....C.BC........BB.....BB..B.B..B...B
.............B....B.B..........C.....C....C......................C......BC.......B...B............B........B.B....B........

output:

BBBCCBCCBCCBBBBCCBBBBBBBCBBBCBBCCCBCCCBCBCBBCCCBBBBCCBCBCBBBCBCCCBBCBBBCCCCCCBBCCBCBCBCCBBCCCCCCBCCBCBCBCCCCCCCBCCCCCBBBCCCCCCCCCCBCCBCCCCBCBCBBBCCCBBBCCCCBBCBCCCBBCBCBBCB
CBBBCBBCBCCBCCBBBCBBCCCBCBBCBBCCCBCBCCBBBBCBBCBBBCBCCBCBBCBBCBCBCCCBCBBCCBBCBCCBBCCCBCBBBBCBBCBCCBBCCCCBCCBBCCBCCBBCCBBBBBBBBBBC...

result:

ok 292 lines

Subtask #7:

score: 1
Accepted

Test #54:

score: 1
Accepted
time: 19ms
memory: 20808kb

input:

500 500
...C..CBBCB....CBBBC....CB.C....BB.CCB.BBB...B.CC.B..CBBC.BCBCC....CBB.C.BCCB.C.C.CB.C.B.BC..B..BCCCB...B.B.B.CCBB.CB....BBCC.CCCC.C...CBB...BB...BBC.C..CBCBCCC.CB..C.CC.CBC.B.C..B....C.CBB......C.BC.BB.C.C..CB..B.C..CB......CCBC...BBB.BB..CC...C....C.B...B.BB.B..CC.B.C.BCBB.B.CC.BCBB.B...BB...

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 500 lines

Test #55:

score: 0
Accepted
time: 3ms
memory: 19964kb

input:

66 211
..C.....BCC....B.BBB.....B....CB..BB.CCB.B..BC.C.....C.C..BC....B.B..B...CBB.BC.....C..CCB..CCBCCC.B.BB.CBBC..B.B.CCB........B.BC.BB.BB...C.B...BCB.B.B..CC..C.B.C.C..BBC.B........C....B....CB....BB......CBCB..BB
B.CC.B..CBC..B...CCC.....BB..CBCC.C...BB.C..B.BBB.BC.C...BB.BB..B.BC.CB.BC.BC.......

output:

B..................................................................................................................................................................................................................
C..........................................................................................

result:

ok 66 lines

Test #56:

score: 0
Accepted
time: 13ms
memory: 20000kb

input:

404 268
.....C...B..........CB....B....................B.....C.............B.B..........................B............C..B..........C.....CC.....B..........BC...C..........C.C....C...............................C.........B...................C......B.....B...C..................
..........B...............

output:

............................................................................................................................................................................................................................................................................
C.................................

result:

ok 404 lines

Test #57:

score: 0
Accepted
time: 3ms
memory: 20040kb

input:

384 57
....C.....BC..BC..B....B...B.......BB.........C.....BC.B.
CCCB.CCBBCBCBBCBC.CBCC.C.B.CBCC..B.CBCB.BBCB..CBB.BB.CCBC
BBBBB.CCBBCBCBBBCBBBCCCCCCCCBBCBCCCBBBBBCBBCBCBCCCBCBCCBC
..CC.....C..B.........B..B....C..BB.CC.CB.CCCCCB......C..
..CC.B.BCC.C.CBB...C..CB..BB.CBCCB...B.B.C.CB...B....BC.C
CBC...

output:

BBCCBCBCCCCCCCBCBCCBBBBCCBBBBBBCBCBCBBCCBCCBCCBBBCBBCBCCB
BBCBBBCBBCCBBBCBCBCCCCCCCBBBCBBBBBBCCCCBCBCBCCBCCCCCBCCBB
.BCCCCCCCCCBCBCCCCCCBCCBCBBCCBCCCCCCBBBCBCBCCBBBCCBCBBCCC
.CBBBBCCBBCCCBBBBCBCCCBBBCBBCBCCCBBCCCCBCBCBCCCBCBBBBBBBC
.BCBCCBBCCCCBCBBBBCCCCBBBBBCBCCBBBCBBCCCBBBCCBCCBCBCCBBCC
.CCBBBCCBB...

result:

ok 384 lines

Test #58:

score: 0
Accepted
time: 6ms
memory: 19968kb

input:

36 316
......BB..CB.BB.BCB..B..C.CBCB..........B....CBC..B.BCB..B.B.B....C.BC..B..CCB..CC.C.C.....BB...BC.CCCB....CBC.......C..........CCCC...C..C...C.C..C....C.B..C.BCB..BBC....B....B....C.CB.BC..BC.B.....BB...B..BB...C.BBB...CCCC...B.B..C....CCCC.C....BC.C....C.....C.CB.B..C.C..C..B....BCC..CCC..B...

output:

CCCCCBBBBCCCCCBCBCBBBCCBBCBCCBCCCBCCCBBBBBBCBCBCBCBBCBBBBBCBCCBCBBCCCCBCCCCCCBBBCBCBBCBCBCBBBCBCCCBCBBBCBBBCCBBCCBCBCBBCBBCCBBCCBCCCCCBCBBCCBBCBC..............................................................................................................................................................

result:

ok 36 lines

Test #59:

score: 0
Accepted
time: 0ms
memory: 18308kb

input:

173 369
................B...............B......B................BC.........C............C.............B............B.....B....B............C..............C....C...............................................C.........B.....B...........C...C...............B.........C.....C..C..............C..B..........

output:

BCBCBCBBBBCCCCBBBCBBCBCBCBBCCBCBBBBCCCCBCCCCBBBCBCB............................................................................................................................................................................................................................................................

result:

ok 173 lines

Test #60:

score: 0
Accepted
time: 13ms
memory: 18516kb

input:

287 386
BBBCCBBBCBCB.CBBCB..BCCC.B.CBBBBCBCC..BCBCBBC.CCBBCBBBCCBBBCBCBCCCBCCCBCBCB..CBCBCCCC.BBCBC.BCCBCCCBB.BBBBBBBCCBBBBCB.BCCCBBBCCCCCBBCCCCBCB.CCC.B.BCBBBCBCCCCBCCCBBBBBCBCB.BBCCBCBCCBBBCBCCBB.BCB.BBBCBBC.BCC.CCBCCCBBBCBBCCCBCBBCC.CCBB.CCC.BC.CCBBBCCCCBBBC.BB.CCBBB.CBBCCBBBBB.C.CBBBBBCBCBBBBCBB...

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 287 lines

Test #61:

score: 0
Accepted
time: 3ms
memory: 9964kb

input:

79 352
CC...B.C.....CC.CC.C..CC.C..C..CCC.B.C.B...BC.B......B.BBBBBC..B.....B.BBC.C.CC.CC..B..CCBC.BBBBCB..C..B.C..B..CC.BBBC..C..CCC...B...B..BC.BB.CCC...CC....B...BCBB.B..B..BCC.CC.BC..BC.CC.CBB.CCB..BBC.CB.CCCC..C....C.......B..BC.CBBC.B....B...C.C.B.C....B.BCC.CB..BB.CCC.B.CC..C.BCC.C......C.BC....

output:

CCBCCCCCCCCCCCCCBCBBCBBBBBBBCBBBBCCCCCCBCCBCBBBBCBCBCBCCBBBCCCCCBBBCBBCCCCCBBCBBBBBCCCCBCBCCCCBBCCBBBCCBCCCCCCBBCCBBCBBCCBCBBCCCBBBCCCBCCCBCCCCBCCCCBBCCBBBBCBBBCBBBBBBCBCCBCCBCBC.............................................................................................................................

result:

ok 79 lines

Test #62:

score: 0
Accepted
time: 17ms
memory: 20816kb

input:

424 488
BCCBCCCBC.BBBCCBCCCBCCCCBBBBCCBCBCCBCC.BBCCBB.CCCCBBCBBCCBCCBCBBBCCBCBCCBBCCBCCCCCCBBC.CCBCCBBBBBBCBCBBCBCBBBBBCBBCCCBCCBC.CBCCBC.BBBCBBBCBBCCCBCCBBBCCCBCCCBBBBC.BCCBBBCCCCBCBCCBBCCBCCBCCCCCBCBCBBBC.CBCBBBCCCCBB.CCCBBCBBBBCCCBCCBBCCBBBBBCCCCCCBBCCCCBB.CBCBBBCCCBBCBBCBBCCBC.BBBBCCBCCCBCCCBBBB...

output:

BBBCCCBCCBBCBCCCBCCBCBBBBCCCBCCCCBCBCCBCBCBCCCBCCCCBCCCBBCCCBCCCBCBCCBCCBCCCBCBBBBCCBCCCCBCCCBCCCBCCBCCCCBCBCCBBCBCCCBBCBCBCCBBCCCCBBBBCBCCBCBCBCCBCBBCBBBBCCCBCCBBCCBCCCBBBCBCBCBBCBCBCBBBCCCCBBBCCBCCCCCCBCCCBBCCCBBBCBBCCBBCCCBBBCCCBCCCBCBCCCBBCBBCBCCBCBCBCCCBBBCCBBBBBCBCBBCCBCCBCCBCBCBBBCCBBBBBCBBCB...

result:

ok 424 lines

Subtask #8:

score: 1
Accepted

Test #63:

score: 1
Accepted
time: 30ms
memory: 20996kb

input:

500 500
CC.CC...B..BCCB..C..C..CBBB..C..C..CCB.BC.CB.CCCCC..C......BC....BB.B.BB.....C...B..BBC...C....C.BB...BCBB.BCB.CC...B.CC....B.CC.B..BC.CB...C...BC.BBB...B.B.B..B.CB.CBBC..B.....CB.CB..BB.B.CCB.B.B..CC.B..CC.C.BB.BC..B.CBC.BB.....C......B.......C..C..BCB.BB.C.B....B..CB...B.CB...B.BCC.B.BB......

output:

CCCBBBBCCBCBBCBBCBBCCBCBCBBBBCBCBCCBBBBBCBCBCBCBCBBBBCBCCBCCCBBBCBCBBBCBBCCCBBCBCBBBBCCCCCCBCCCCCBBBBCCCBBCCCBBBCCBCCCBBBBCBCBCBCBBCCBBBBBBCCCBBBBCBCBBCBBBCBCCBBBBBCBBBCCBCCCBBCBCBCBCBBBBCBBBBCCBBCCBCCCBBBCCBCBCBCBCCBCCCBBBCCCBCBBCBBBBCBCCBCCCCCBCBBCCCCBBBBBBBBBCBBCCBBBBBBBCCBBCCBBCCBBCCCBCBBBBCBCBB...

result:

ok 500 lines

Test #64:

score: 0
Accepted
time: 3ms
memory: 19964kb

input:

68 342
CBC...B.C.CBBCCC.C.BBBCCB.BB.C...BCC...BCC...B..B.C...C.BCB.BB...C..B.B.C.B.BC...CC...B.BCBB...BBB.C.CBB......B..BC.B...BC..B..B.B.BB.BCBB.B..BCBCC..B....CC.BBC...BB...BC..BBBCBC...BC..C..BBC.C.C.CCB.B...B.CBBC.BB.CCCCC.C..C...C..B.CBB.B..C..BBBCCCB...BCC.BBBCC..CBB..B..B...C.BB...BB.B..CBB.....

output:

BBBCBBBCCCBCBBBCBBBCBBCCCCCCBCBBCBCBBCBBCBCCCBBCBBCCBBCBCBCCBCBBBBBCCBBCBCCCBBBBBBCCBCBCCBCBCBBBBCBCBCBBBCCCBCBBCBBBCCCCCCCBCCCCCCBCBBCCBBBBBCBBCBBBCCBBCBCBCCCCCBBBBBBCCCBBCCCCBBBBBBCBCCBBBBBBCBBCCBBCCBBBCCBBBBBCBBBBCBBCBBCBBCCCCCBCCCCBCBCCBBBBCCBBCCCCCCBBCBBCCBCBBCBCBCCCBBBBCCCCBCCCBBCCBCCBBCBCCBBB...

result:

ok 68 lines

Test #65:

score: 0
Accepted
time: 8ms
memory: 20584kb

input:

306 316
.C.B.........C....C...B.BC.BB....C....C..C.........B....CC..............B..C....C.....C.B..C.C.C.......C.......BC....B..................BC.....B........C..........CB.B.B.................C..B......................C..............BBB.C...B..........B...............................C....B.CC........

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 306 lines

Test #66:

score: 0
Accepted
time: 6ms
memory: 19988kb

input:

157 285
.BB..C...B.CBC.CC.B..CB......CC..B.CCB....BB.C..B.CB..CCCC..C.BCB.C..CC...C.C.BC....CB...BB...B.BBB.B.B.BCBCB...C.BC.CCB..B....B.BC.B....B.CCB..B.......BB.BCC.C.C.C...B...B.C.....CBB..BCBB.BC.B..C...B.B....BC..CCBBB.C..B.C..C.C.C.BCC...BBBC.B...C...C.C.BC.B.....CB.C..CB..B.C........CB
..C..C...

output:

.............................................................................................................................................................................................................................................................................................
.................

result:

ok 157 lines

Test #67:

score: 0
Accepted
time: 1ms
memory: 20444kb

input:

227 409
....CB................C.........B..........BCC..C..C......B...B........C...B...C.........C.....C..B.....B........................B.....B....B..............................................B....C.......B....C...........................C.....B...........C.........B......B.B.............C.C........

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 227 lines

Test #68:

score: 0
Accepted
time: 4ms
memory: 19904kb

input:

25 418
.................................................................C....................B......B................................B.......C...............C................C..............................................................C............C....................................................

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 25 lines

Test #69:

score: 0
Accepted
time: 10ms
memory: 18508kb

input:

297 215
.....B.B..C.B.CBBB.C.BBB....C.BC....B.C.B.B...CC....C.B..BB..B....B..C.C....CCC.....CB..C.B.BB..BBCCB.B.C..C...CB.B.C...BC..BC.CCC..........CCBB.CB.B.CBC.....BC..B.BBCBCCC..BBBCB..BBCB.CC.BCC..C..C.C.B.B.CB.BB.CC.CB
.CB.CCBC....C.C.BC....BB.C.BC....B.BC..CBB.C.....CCBB.CB....B...C.CC...BB.B....

output:

BCBBCCBBCCCCCBBBCBBCBBBBBCBCBBBBCBCBBCBCBBBBCBBBCCBCCCBCBCBBBCCBBCBCBCCBCCBBCCCCCCBBBBCBCBBCCBCCCCCBBCCCCCBCBBBCBCCBCBBCCCCBBCBCCCBCBCBBCCCCBBCCBBBBBBCCCBCCBCBBCBCCCCCBBBCCBCBCBBCBBBCCBCCBCCBCCCCCBCBBCBBCCCBCBCBCBCC
BCCBBBBBBBCCBCBCBBBCBBCBCBCBCCBCCBCBCCBCCBCCBBCBBCCBBBCCBCBBCBCCCBBCCBBBBBCCCBBCBCCC...

result:

ok 297 lines

Test #70:

score: 0
Accepted
time: 6ms
memory: 18460kb

input:

270 275
.....C..BB.CB..........C.BC..B...........B...BC.........BC.B...B......BB............C.....B..B......B..CB.B......C.........C.BB..B..C..C..........B.......C.......C....C.....CC............C.....CB.....CC.......B.B...........CC.B........C.......C...C.....B............B......B.
.........B..B.CC...

output:

..................................................................................................................................................................................................................................................................................C
...........................

result:

ok 270 lines

Subtask #9:

score: 1
Accepted

Test #71:

score: 1
Accepted
time: 20ms
memory: 20388kb

input:

500 500
...................................C................C........C......B........C...........B..BC..................................................................C.....C.............C..............................................B...........B.........B.........B...B..C............B...............

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 500 lines

Test #72:

score: 0
Accepted
time: 12ms
memory: 19000kb

input:

499 103
BCBBC....B..C.BCCCC.B.BBC...CC.B.CCCCCCB....B.CBCC..C.BBC.BB.CBC..CC..C.BB.B..B.BBC.B.B....C.BB.C.B.B.C
..CBB.......C.CBCCB.CC.CC..CCB.B..BCCC.B...CB..BB...B.CCBBC..BBCCBBCB.C..CCCB.CCCCC.B...C..B.C..C.....C
CC.B....BB.BB.CCCCB..BBBCB.BBB.C...BB..BC..BC..BCCB...CBC..C..C.BBB...BCBCBC.BBC.BB....

output:

.......................................................................................................
.......................................................................................................
C..............................................................................................

result:

ok 499 lines

Test #73:

score: 0
Accepted
time: 7ms
memory: 20000kb

input:

244 216
BCB.C..B..B.BBC.......B.CC..B.BC..B...CC.BC.C.CB.C.B.CCC......CCC..B....B.....B.B..C..B..C..C.C..CCCC..C.C..C....B.C.BBC.C.B..C..C...C.CBB..CB...C...BCB.B...C..CBCB...B.CC.BB..CCB..BCC...B.B.......BBBC..CB........BCB
C.B.........CBC..C..........C..CBC....B..CB.B..C.C.B.BBC..B.B.B.B..B.CBCC.B...

output:

BCBB....................................................................................................................................................................................................................
BBCC..................................................................................

result:

ok 244 lines

Test #74:

score: 0
Accepted
time: 6ms
memory: 18516kb

input:

281 97
BC...........C...B.B.B..BBBCB.BC.CBCC.BBB.CBBB.B.B.B.CC.C.B.B.BCB.B.C.B..C.B...BC.B..C...CB.B.CBC
.C...C.C.CBB..C..B...B..CCCCC......CBC.CB.BBCBCC.C..B...CC.CB...B.B.C.B....C..B..CCB..C...C..B.CB
..B...B..CB.BCB....BCC...C.BB....BCBCB.B..CB.B.BCB.BBB..C...C..BB.BC..C....CC..CC.C....CBB.CC.BCC...

output:

.................................................................................................
.................................................................................................
.................................................................................................
.........

result:

ok 281 lines

Test #75:

score: 0
Accepted
time: 3ms
memory: 15964kb

input:

32 498
CC...CBBCB.CBC.BB......BBCCBCBCBCB..CB....CBBCC.B.B..CCB.C..BCCB..B.CC.B..CC.C...BCCBB.B..BCC....BCCC...BB.B..C.BCBB.CC.BBC.B.BBCCBBC......B.CB..C.CBC..BCCB..C.BB.BBB..B..CCBCCBB....BB....B.BC..CCBB.B.CCBC..BBBC.CC.BB.BCC..BCB..CBB..C.C.C.CC.B....CC.BB..BB.....C.B..C.C.CC.BCBB.BB..C..C..CC.BC...

output:

.............................................................................................................................................................................CBBCCBBCCCBBCCBBBCCCCBBCBBBCBBBCCCBBCBCBBBBBBBCCCBBBCCCBBCBBBBBCCCBCCBBCCCBBCCBCBBCCCCBBBBCBCCBBCBBBCBBBCCBBBCCCCCCBCCCBCCCBCCB...

result:

ok 32 lines

Test #76:

score: 0
Accepted
time: 5ms
memory: 18608kb

input:

303 415
.............B.....C.B.B...B...CBB.............C............B...........BC.B................C....CB.........C.C....B.....C.B..B.........C...BB...........B....B.C....BB.............BB....C...........BCC.B...B.C...B..B...CB....C....CC...CB......C..............B......B....B..B..........CB.........

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 303 lines

Test #77:

score: 0
Accepted
time: 11ms
memory: 20176kb

input:

302 277
CC..B.CC.BBB.CC..C.BBCB..CCBBBC.CBC..BB..C.CB..CB.CCB.B....CCCCB.BCBCC..B.....B.C.BC..C.CC..B.C..BCBCB....BB..B...B.C....C..B..CB..CBC.C.B...BCBC..B..B.C...BB.CC..BCB.C...C.C...C.CB.C..B.CB..B.B...CC.BCB...BC...C....BBBB.B.CBBCCC..B.CCCB....C.CC.....CB.C.B...CC..BCCB.......B..
C.BCCB..C.CBC....

output:

.....................................................................................................................................................................................................................................................................................
.........................

result:

ok 302 lines

Test #78:

score: 0
Accepted
time: 1ms
memory: 9700kb

input:

94 188
CBC.CCC...BC..C.CB...BCCB.CBB..BB.C..C...C...B.BB.BCC.C.BC.CBB.C..CBC..C......CC.C..B...C.B.CCCBBCC.C..CCBBBB...CB.CB..B.BB.....CB.C...C....BB...BBC.CB..B....CC.B.BBC....CCC.C......CCC.C.C
....C.B.B.CBC.B.BB.B....CBC......C...C.CB..BBC.BB....B.CC.BCB.B.CC.C.CCCCC.C.C.BBCB....BCBB..CB.B..C.......

output:

..............................................................................................CBCCCCBCCCBBCCBCBBBBCCCBBBBCCCBCCBBCCBCCCCCBCBCCCBBCCCCCBBBBCBCBBBBCBCCBBBBCCBBCCBBBCCCCCCCCCC
...........................................................................................CBBCBCBBBBCBCCCCBBBC...

result:

ok 94 lines

Test #79:

score: 0
Accepted
time: 20ms
memory: 20304kb

input:

446 359
.C..CBC..CCBBBC.BC.C....B.B..C...BBB....B.BC..B..C.B..B..B.CB.CC..B..B...C.BB.C...BB...CC..BCB....B......CB.CBCBB...CB....B.CCCB.CB.CBC..B..BB.C....CCCCBC.B...B....CCC..C.B....B.B.CCC.BBCCC..C..CBB.C.BB......BC..BCBBC..BB..BB....C....CB..BC.C.C.BB.CCC.BB.BB.CC..BCCBCCB.B.CCBBB.BB..C....BC.BC...

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 446 lines

Subtask #10:

score: 1
Accepted

Test #80:

score: 1
Accepted
time: 18ms
memory: 19008kb

input:

500 500
.BBB.BCB.CCCBCBCCB.CB.CBBBCCCCBBBCBBCBCC.B.BCBCBBB.BBBBCCBBB.BBBBCCC.CCBBBCBCCCBBBCBCBBBCBBC.C.CBBBBBBC.BCCBBBBCBBCB.BCBB.CC.BCBB.CBB.BBBCCBCBCCBBC.CCCCBB.BBCBBBCBBBBCBBCBC.BBBBCBBBCCCC.CBBCCCB.C.C.CBBC.CCBBCCCCCCBC.BCCCBCCBCB.BBCBCCB.BCCBBC.BB.BCCCCCCCCCCCBBCC.C.CCCCBBBCCCB.BBBCBB..B.B.CBB....

output:

...............................................................................................................................................................................................................................................................................................................

result:

ok 500 lines

Test #81:

score: 0
Accepted
time: 6ms
memory: 18136kb

input:

114 336
.B.BC.BC.B.C.CBCC.C.BCC..BCB....C.CCBBBBBC.CCC.B.CBBB.B.BC.BBB.B.....C.....C.C..B..BCB..C.CC..C...BCC...BC..CB..BCB..C.BC.....CBCCC.C..CCBBCCB.C.B.C..CC..B..C.....B.C.C.CB......BB.C..C..CCBCC.B.BCCC.CCCBB.C...BCCCB...C...C...B.CBC.CBC.CBC...C..BBB.C...CC..BBB.CCBCB..CC.B.B..BCB.C.BBC.BBB..C....

output:

B..............................................................................................................................................................................................................................................................................................................

result:

ok 114 lines

Test #82:

score: 0
Accepted
time: 1ms
memory: 19944kb

input:

122 22
BBBCBBCBCCBBCCBCCBCBBB
BCC.C.C.B.....C..C....
....................B.
C...BB..C.B...B.B..C..
CBCBCCBCBBBCBBCCBBCCBB
..C.C.B....B..C..B.C.B
.........C...B....C.C.
BBBBCBBB.BBBB.CCCCBBCC
CCCB...CB.CBBC..CCCBCB
.BBC.CCBCBCCCCCBCCBBCB
...BC...B..........CB.
......................
BCBBBCCBCBBBC.CB....

output:

BBCCCCCBCBBCBBBCCBBCBB
CBBCCBBCCBCCCBBCBBBBCC
BCCCBBCCBBBCCBCBBCCCBB
BBCBCCBBCCBBBCBBBBCCBC
BBBBCCBCCCCBBCCCCBCBCB
BCBCBBBBCCBBCBBCBBBCBB
BCBBCCBBBBBCBCBCBBCBBC
CCCCBCCBBBBCBCBCBCCBCC
.CBCBCCCBCCBCCBCBCBBBC
.BCCBCCCBBBCBCCCCCCBBB
..CBCBBBBCBCCCCBCCBBBB
..BBBCBBBCCBCCCBBBBCCC
..BCCCCBCCCBCCCCBBBCCB
....

result:

ok 122 lines

Test #83:

score: 0
Accepted
time: 7ms
memory: 19952kb

input:

76 132
......C..........B.CCC....B.C..BB....CC......B.C..BBBCB..C......C..C.CC....C......C..C....CC..C.BC...CC......C...B..B.CC....B.B.C...
.BC...C.......C.B..BCC.BC.C.BC..BCB....CBCC....CBC.B...C..B...B........C.B..C.B..C.C..BC.......CBB.BC.CC...B.B.BBB.CB.CCB.BC.CC.C..B
....CC..C....B.C.........B....

output:

BCCBBCBBBBBBBCCBBCBCCCBCBBBBCCBBBBBBBCBBBBCCCBBBBBBBCBBCCBCBCCCBBBBBBBBCCBBCBBCBBBBBCCBBBBCBBBCCCCCBCBBBBCBCCCCCBCCBBBCCCCBCBCBCBBBB
.BCBCCBCBBBCBCCCBCCBCCCCBCBCBCBBBBCCBBCCCCBCCBBBBBCCCCCBBCCCBBBCCCCBCCBBCBCCBCBBBBBCBCBCCCBCCCBCBBCBBCCBBBCBCBCBCCBBBCCBBBBCBCBCBCCB
.CBBCCBCBCCBBCCCCCBCBBCBCBCCCBCCCB...

result:

ok 76 lines

Test #84:

score: 0
Accepted
time: 5ms
memory: 18432kb

input:

239 12
.BCBCCBBCBBB
CC..CBCCBBB.
BCCCBBC.BBBC
BBBBBC.CBBB.
C.CCC.C.BCBC
.BBBCCC.CB.B
BC.CBC..CBBB
..CCCCCCCB.C
CCBBBCCC.C..
.C.C.BC..BBC
CCC.CCCCBCB.
...CCCCCBB.C
.BC.BBBBBCCB
CCBBCCC.CCBC
BBBBB.BBBB.B
CCC.CBCC.CBB
CCBCC.C.BC..
.C..B.BCCCC.
BC.B.CCCCCBC
BCCCBC.CCCBB
CCCCCBBC..BB
CBCC.CBCC.BC
BCBCCCB...

output:

............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
............
....

result:

ok 239 lines

Test #85:

score: 0
Accepted
time: 8ms
memory: 19992kb

input:

263 73
CBBC...CB...BCC.CCC.B..BCB.C..CC.BC..C.C.C..CCCC.B...BCC.CBC.BCC.CBCBCCB.
B.CCBB.CCBCBBCBB..C..BCB.CBB..BC...C.BCC...B.BC.C.....B.B..BBBBC.B.CBB..C
B.B.C.BCB.....B.CCBBBCCC.C..CB.B.C.CC..C..BB..CCB.C.BBBCBC.BB..BBCB...CBB
.BCCBCCB..BB.CC..C..CBBB.BBC.C.BCBBCCC.B..BCC.BCB..CB.C..BBB..B.B.CBBBB...

output:

.........................................................................
.........................................................................
.........................................................................
.........................................................................
.......

result:

ok 263 lines

Test #86:

score: 0
Accepted
time: 6ms
memory: 20004kb

input:

228 400
BCBBCB.CB..BB..C..B.BC.C....C.C.B...C.C......B...CB..C.B..B.C....B..B.....C....B.BC.B.......C.BC....CCCCBBC..C..BBCBC....C.C.BBC...B..C.B.BB.............C..C.B....CBBB.B..C.BBBCB.B........B..B....CB.BCB.B.C.CCC..CC..BCCBC.BCC..B.....BC..B....B.......C.....B.C.B.....BC..B...B.C...C..B....BB.C...

output:

...............................................................................................................................................................................................................................................................................BCCBBBCCBCCBBBBCCBBBBBCBCBBCC...

result:

ok 228 lines

Test #87:

score: 0
Accepted
time: 2ms
memory: 10640kb

input:

445 22
....C..CCBBCBCBB.B..C.
....C..CB.B...B.CBCCC.
..CBBBB..CBBB.C.BCC.CB
CB....CCCB.B...CC..BC.
...........C..BB.C.CC.
B...CC..C..BCC.BCCC...
B.C...B...C........BC.
.C.BB.C..BCCB.....CC..
.B.CB...C..BB..CBCCBCB
..B.B.B.B..B..BBB..B..
BBB.B..C.C.C.CCBB.B.BC
BB.C...B..C.C..B..BB..
C.B...CB.C.B.C.C....

output:

CCCBBCBCBBBC..........
CCBBBCBCCC............
CBBBBCBBBCBCCCB.......
CBCCCBBCCBC...........
CBBCCC................
BCCCBCCBCCC...........
BCBCBC................
CBBCBCCBCC............
BCBCBBCBCCBCB.........
BBBBBBBBB.............
BBBBCCCCCBBBBC........
BBCBCCBBB.............
CBCBCBCCB.............
B...

result:

ok 445 lines

Test #88:

score: 0
Accepted
time: 27ms
memory: 18820kb

input:

456 335
C.BC.C..CBC.BC...BC...B....CC...CB...C..CC.BCCBCCC.B...C..C..C.B....C.B.BB.B.B..C.B.BB.C...BBCB..CB...BB..BC.C..B.CB.C.CC.BBCCB.B..B...B..BCBBB.B.B.C.BC...CB.BB.B.C......BBBBB.C..B...C.BCC.C.BC.BC.C..B...C.....BBB.C.BCC.B...B.CBCBB.CCB.C...BCC.BC.C.C.BB.......BC.BB..C.CBCBCC.CBCCCCC.....BCC....

output:

.BCCCBBBBCBBCCBBBBCCBCCBBCCBCBBBCCBCCBBBBCBCCCBBCCCCCCCCCBCCCBCCBBBCBBBBCCCCBCBCCCBBBBBBCBBBCCBBBCCBCCBCCBCBCCBCCCBBBCCCBCBCBBBCCCCBBBBBCCCCCCCCCBBBBBBBBCBBBCCCCBBBBCBCCCCBCCCBCBBCBBCCCCBBCCBBBCCCCBBBBCBBCBCCCCCBCBBCBBCBCCCCBCCBCCBCBCCBBCCCCBCCBCBBBBCCBCBCBCCBBBCCBBCBBCBCCCCCBCBBBCCBCBCBBCBBCCBCBCCB...

result:

ok 456 lines

Extra Test:

score: 0
Extra Test Passed