#include <iostream>
#include <string>
using namespace std;

int w, h;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
string f[51];

void solve(int x , int y , char c ){
	for(int i=0 ; i<4 ; i++ ){
		int mx = x + dx[i];
		int my = y + dy[i];
		if( mx < 0 || mx >= w || my < 0 || my >= h ) continue;
		
		if( f[my][mx] == '.' ){
			f[my][mx] = ( c == 'W' )? 'w' : 'b' ;
			solve( mx , my , c );
		}else if( (c == 'B' && f[my][mx] == 'w') || (c == 'W' && f[my][mx] == 'b') ){
			f[my][mx] = '?';
			solve( mx , my , c );
		}
	}
}

void debug(){
	cout << "debug : " << endl;
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			cout << f[y][x];
		}
		cout << endl;
	}
	cout << endl;
}

int main(){
	while( cin >> w >> h , w || h ){
		int white=0, black=0;
		for(int i=0 ; i < h ; i++ ){
			cin >> f[i];
		}
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( f[y][x] == 'W' || f[y][x] == 'B' ){
					solve( x , y , f[y][x] );
				}
			}
		}
		//debug();
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( f[y][x] == 'b' ){
					black++;
				}else if( f[y][x] == 'w' ){
					white++;
				}
			}
		}
		cout << black << " " << white << endl;
	}
}