//* Problem  : 1219 - Quadtree
//* Contest  : acm.tju.edu.cn
//* Origin   : University of Ulm Local Contest 1999
//* Type     : Solution
//* Date     : 2008.06.06
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 8.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long
#define INF 1000000000
#define EPS 1E-8

#define ALL(a) a.begin(), a.end()
#define PB(a, v) a.push_back(v)
#define MP(a,b) make_pair(a, b)
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
#define FORO(i, obj) for (int i = 0; i < (int)(obj.size); i++)

int n, a[512][512], pos;

char s[512*512 + 1];

void encode(int x, int y, int n)
{
	if (s[pos] == 'B')
	{
		pos++;
		for (int i = x; i < n + x; i++)
			for (int j = y; j < n + y; j++)
				a[i][j] = 1;
	}
	else if (s[pos] == 'W'){pos++;}
	else
	{
		pos++;
		encode(x, y, n / 2);
		encode(x, y + n / 2, n / 2);
		encode(x + n / 2, y, n / 2);
		encode(x + n / 2, y + n / 2, n / 2);
	}
}

int bits(int x, int y)
{
	return a[x][y] * 1 + a[x][y+1] * 2 + a[x][y+2] * 4 + a[x][y+3] * 8;
}

char val(int v)
{
	return v < 10 ? '0' + v : v - 10 + 'a';
}

int main()
{
	scanf("%d%s", &n, s);
	encode(0, 0, n);
/*	n = 16;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			printf("%d", a[i][j]);
		printf("\n");
	}*/
	printf("#define quadtree_width %d\n", n);
	printf("#define quadtree_height %d\n", n);
	printf("static char quadtree_bits[] = {\n");
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n / 8; j++)
		{
			printf("0x");
			int v = 0;
			v = bits(i, 8*j + 4);
			putchar(val(v));
			v = bits(i, 8*j);
			putchar(val(v));
			printf(",");
		}
		printf("\n");
	}
	printf("};\n");
	return 0;
}
