#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int i,j,w,h;cin>>w>>h;
	if(w*h==0){return false;}
	vector<string>mat(h);
	for(i=0;i<h;i++){cin>>mat[i];}
	queue<tuple<int,int,char>>que;
	static int mita[100][100];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			mita[i][j]=0;
			if(mat[i][j]=='W'){que.push(mt(i,j,'w'));}
			if(mat[i][j]=='B'){que.push(mt(i,j,'b'));}
		}
	}
	while(que.size()){
		int y,x;char c;
		tie(y,x,c)=que.front();que.pop();
		if(x<0||y<0||x>w||y>h){continue;}
		if(c=='w'){
			if(mita[y][x]%2){continue;}
			mita[y][x]+=1;
			if(mat[y][x]=='W'){}
			else if(mat[y][x]=='.'){mat[y][x]='w';}
			else if(mat[y][x]=='b'){mat[y][x]='r';}
			else{continue;}
		}else{
			if(mita[y][x]/2){continue;}
			mita[y][x]+=2;
			if(mat[y][x]=='B'){}
			else if(mat[y][x]=='.'){mat[y][x]='b';}
			else if(mat[y][x]=='w'){mat[y][x]='r';}
			else{continue;}
		}
		
		
		if(c=='w'){
			if(y>0&&(mat[y-1][x]=='.'||mat[y-1][x]=='b'||mat[y-1][x]=='r')){que.push(mt(y-1,x,'w'));}
			if(x>0&&(mat[y][x-1]=='.'||mat[y][x-1]=='b'||mat[y][x-1]=='r')){que.push(mt(y,x-1,'w'));}
			if(y<h-1&&(mat[y+1][x]=='.'||mat[y+1][x]=='b'||mat[y+1][x]=='r')){que.push(mt(y+1,x,'w'));}
			if(x<w-1&&(mat[y][x+1]=='.'||mat[y][x+1]=='b'||mat[y][x+1]=='r')){que.push(mt(y,x+1,'w'));}
		}else{
			if(y>0&&(mat[y-1][x]=='.'||mat[y-1][x]=='w'||mat[y-1][x]=='r')){que.push(mt(y-1,x,'b'));}
			if(x>0&&(mat[y][x-1]=='.'||mat[y][x-1]=='w'||mat[y][x-1]=='r')){que.push(mt(y,x-1,'b'));}
			if(y<h-1&&(mat[y+1][x]=='.'||mat[y+1][x]=='w'||mat[y+1][x]=='r')){que.push(mt(y+1,x,'b'));}
			if(x<w-1&&(mat[y][x+1]=='.'||mat[y][x+1]=='w'||mat[y][x+1]=='r')){que.push(mt(y,x+1,'b'));}
		}
	}
	int ansW=0,ansB=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			//cerr<<mat[i][j];
			mita[i][j]=0;
			if(mat[i][j]=='w'){ansW++;}
			if(mat[i][j]=='b'){ansB++;}
		}
		//cerr<<endl;
	}
	cout<<ansB<<" "<<ansW<<endl;
	return true;
}
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3296