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

void CheckBlack(int, int, int, int);
void CheckWhite(int, int, int, int);

int area[50][50];

int main()
{
	int wCount, bCount;
	int i, j, h, w;
	
	while(1)
	{
		wCount = bCount = 0;
		
		scanf("%d %d", &w, &h);
		
		char input[51];
		
		if(h == 0 && w == 0) break;
		
		for(i = 0; i < h; i++)
		{
			scanf(" %s", input);
			for(j = 0; j < w; j++)
			{
				if(input[j] == 'W') {
					area[i][j] = 1;
				} else if(input[j] == 'B') {
					area[i][j] = 2;
				} else {
					area[i][j] = 0;
				}
			}
		}
		
		for(i = 0; i < h; i++)
		{
			for(j = 0; j < w; j++)
			{
				if((area[i][j] & 3) == 1) {
					area[i][j] |= 8;
					CheckWhite(i, j, h, w);
				} else if((area[i][j] & 3) == 2) {
					area[i][j] |= 4;
					CheckBlack(i, j, h, w);
				}
			}
		}
		
		for(i = 0; i < h; i++)
		{
			for(j = 0; j < w; j++)
			{
				if((area[i][j] & 12) == 4) {
					wCount++;
				} else if((area[i][j] & 12) == 8) {
					bCount++;
				}
			}
		}
		
		printf("%d %d\n", bCount, wCount);
	}
	
	return 0;
}

void CheckBlack(int h, int w, int maxH, int maxW)
{
	int i, hh, ww;
	
	if((area[h][w] & 8) != 8)
	{
		area[h][w] |= 8;
		
		for(i = 0; i < 4; i++)
		{
			ww = cos(90 * i * M_PI / 180);
			hh = sin(90 * i * M_PI / 180);
			
			if(h + hh > -1 && h + hh < maxH && w + ww > -1 && w + ww < maxW && (area[h + hh][w + ww] & 3) == 0)
			{
				CheckBlack(h + hh, w + ww, maxH, maxW);
			}
		}
	}
}

void CheckWhite(int h, int w, int maxH, int maxW)
{
	int i, hh, ww;
	
	if((area[h][w] & 4) != 4)
	{
		area[h][w] |= 4;
		
		for(i = 0; i < 4; i++)
		{
			ww = cos(90 * i * M_PI / 180);
			hh = sin(90 * i * M_PI / 180);
			
			if(h + hh > -1 && h + hh < maxH && w + ww > -1 && w + ww < maxW && (area[h + hh][w + ww] & 3) == 0)
			{
				CheckWhite(h + hh, w + ww, maxH, maxW);
			}
		}
	}
}