#include <iostream>
#include <string>

using namespace std;

const int MAX_H = 50;

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

const char mozi[] = "BW";

int w, h;
int flg;
int cnt;

void search( int x, int y, string map[], char c, char nc );

int main()
{	
	string map[2][MAX_H];	/// Black = 0 , White = 1
	while( cin >> w >> h, w | h )
	{
		int cnt_BW[2] = { 0 };

		for( int i=0; i < h; i++ ) { cin >> map[0][i]; map[1][i] = map[0][i]; }

		for( int idx=0; idx < 2; idx++ ) for( int i=0; i < h; i++ ) for( int j=0; j < w; j++ )
		{
			if( map[idx][i][j] != '.' ) continue;
			int BW[2] = { 0 };
			for( int k=0; k < 4; k++ )
			{
				int mx = j + dx[k];
				int my = i + dy[k];
				if( 0 <= mx && mx < w && 0 <= my && my < h )
				{
					if( map[idx][my][mx] == mozi[idx] ) BW[idx]++;
					else if( map[idx][my][mx] == mozi[(idx+1)%2] ) BW[(idx+1)%2]++;
				}
			}
			cnt = 0; flg = true;
			if( BW[idx] && !BW[(idx+1)%2] ) search( j, i, map[idx], mozi[idx], mozi[(idx+1)%2] );
			if( flg ) cnt_BW[idx] += cnt;
		}
		cout << cnt_BW[0] << " " << cnt_BW[1] << endl;
	}
	return 0;
}

void search( int x, int y, string map[], char c, char nc )
{
	if( map[y][x] == '.' )
	{
		cnt++;
		map[y][x] = c;
	}
	for( int i=0; i < 4; i++ )
	{
		int mx = x + dx[i];
		int my = y + dy[i];
		if( 0 <= mx && mx < w && 0 <= my && my < h )
		{
			if( map[my][mx] == '.' )
			{
				search( mx, my, map, c, nc );
			}
			else if( map[my][mx] == nc )
			{
				flg = false;
			}
		}
	}
}