#include "random.h"
#include <cassert>
#include <cstring>

using namespace std;          

int n,cnt;
char s[1000][1000];

int main(int argc, char** argv){
	int seed;
	assert(argc >= 3);
	assert(sscanf(argv[1],"%d",&seed) == 1);
	if (seed == 0) {	
		seed = (int)Time();
		fprintf(stderr,"Using seed : %d\n",seed);
	}
	initrand(seed);
	if (strcmp(argv[2], "corner") == 0)
		cnt = -1;
	else
		assert(sscanf(argv[2],"%d",&cnt) == 1);
	
	assert(scanf("%d",&n)==1);
	for (int i = 0; i < n; i++){
		assert(scanf("%s",s[i]) == 1);
		assert((int)strlen(s[i]) == n);
	}

	if (cnt == -1){
		int x = R(0,1)*(n-1);
		int y = R(0,1)*(n-1);
		s[x][y] = 'B' + 'W' - s[x][y];
	}

	for (int i = 0; i < cnt; i++){
		int x = R(0,n-1);
		int y = R(0,n-1);
		s[x][y] = 'B' + 'W' - s[x][y];
	}
		
	printf("%d\n",n);
	for (int i = 0; i < n; i++)
		printf("%s\n",s[i]);
	return 0;
}
