#include <bits/stdc++.h>
using namespace std;

template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
typedef pair<long long, long long> P;

void solve(int w, int h){
	vector<string> a;
	readVector(h, a);
	int b[h][w];
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j)
			b[i][j] = 0;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
			int t = 0;
			if(a[i][j] == 'B') t = 1;
			else if(a[i][j] == 'W') t = 2;
			if(t > 0){
				queue<P> q;
				for(int k=0; k<4; ++k){
					int nx = i+dx[k];
					int ny = j+dy[k];
					if(0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.' && (b[nx][ny]&t) == 0){
						q.push(P(nx, ny));
						b[nx][ny] += t;
					}
				}
				while(!q.empty()){
					P p = q.front();
					q.pop();
					for(int k=0; k<4; ++k){
						int nx = p.first+dx[k];
						int ny = p.second+dy[k];
						if(0 <= nx && nx < h && 0 <= ny && ny < w && a[nx][ny] == '.' && (b[nx][ny]&t) == 0){
							q.push(P(nx, ny));
							b[nx][ny] += t;
						}
					}
				}
			}
		}
	int x = 0, y = 0;
	for(int i=0; i<h; ++i)
		for(int j=0; j<w; ++j){
			if(b[i][j] == 1) ++x;
			if(b[i][j] == 2) ++y;
		}
	cout << x << " " << y << "\n";
//	for(int i=0; i<h; ++i)
//		for(int j=0; j<w; ++j)
//			cout << b[i][j] << (j==w-1 ? "\n" : " ");
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int w, h;
		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		solve(w, h);
	}
}
