#include "random.h"

using namespace std;

const int MAXN = 100;

int n;
int size;
char b[MAXN][MAXN];

const int dx[4] = {1, 0,  0, -1};
const int dy[4] = {0, 1, -1,  0};

void dfs(int x, int y) {
	if (x < 0 || x >= n || y < 0 || y >= n) {
		return;
	}
	if (b[x][y] == 'B') {
		return;
	}
	if (size == 0) {
		return;
	}
	--size;
	b[x][y] = 'B';
	for ( ; ;) {
		int t = rndInt(5);
		if (t == 4) {
			break;
		}
		dfs(x + dx[t], y + dy[t]);
	}
}

int main(int argc, char** argv) {
	int seed = 0;
	if (argc >= 2) {
		assert(sscanf(argv[1], "%d", &seed) == 1);
	}	
	if (seed == 0) {
		seed = Time();
		fprintf(stderr, "Using seed : %d\n", seed);
	}
	initrand(seed);
	if (argc >= 3) {
		assert(sscanf(argv[2], "%d", &n) == 1);
	} else {
		n = R(2, MAXN);
	}
	if (argc >= 4) {
		assert(sscanf(argv[3], "%d", &size) == 1);
	} else {
		size = R(1, n * n);
	}

	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			b[i][j] = 'W';
		}
	}

	int x = rndInt(n);
	int y = rndInt(n);
	dfs(x, y);

	printf("%d\n", n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			putchar(b[i][j]);
		}
		putchar('\n');
	}

	return 0;
}