#include <bits/stdc++.h>

#define ALL(a) (a).begin(), (a).end()
#define llong long long


using namespace std;
using ARRAY = vector<pair<int,int>>;
using field = vector<ARRAY>;

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

void dfs(field &m, size_t h, size_t w, bool isBlack){
	for(size_t i = 0; i < 4; i++){
		int nexth = h+dx[i];
		int nextw = w+dy[i];
		auto &tmp = m[nexth][nextw];
		if(tmp == make_pair(-1,-1))continue;
		if(isBlack){
			if(tmp.first == 0 && tmp.second != 2){
				tmp = {1, tmp.second};
				dfs(m, nexth, nextw, true);
			}
		}
		else{
			if(tmp.second== 0 && tmp.first != 2){
				tmp = {tmp.first, 1};
				dfs(m, nexth, nextw, false);
			}
		}
	}
}

signed main(){
	while(true){
		int h,w; cin >> w >> h;
		if(h == 0)break;
		field m(h+2, ARRAY(w+2));
		for(int i = 0; i < h+2; i++){
			m[i][0] = {-1,-1};
			m[i][w+1] = {-1,-1};
		}
		for(int i = 0; i < w+2; i++){
			m[0][i] = {-1,-1};
			m[h+1][i] = {-1,-1};
		}
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				char t; cin >> t;
				switch(t){
					case 'B':
						m[i][j] = {2,0};
						break;
					case 'W':
						m[i][j] = {0,2};
						break;
				}
			}
		}
		for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
			if(m[i][j] == make_pair(2,0)){
				dfs(m,i,j,true);
			}
			else if(m[i][j] == make_pair(0,2)){
				dfs(m,i,j,false);
			}
		}
		pair<int, int> ans{0,0};
		for(auto a : m)for(auto e : a){
			if(e.second == 0 && e.first == 1)ans.first++;
			else if(e.first == 0 && e.second == 1)ans.second++;
		}
		cout << ans.first << " " << ans.second << endl;
	}


	return 0;
}


