#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


//0-indexedの幅優先探索
class BreadthFirstSearch
{
public:
	long long int **Used,**BFSResult;
	char **HW;
	long long int MaxH,MaxW,Counter;
	bool Black,White;
	stack<pair<long long int,long long int> >Root;
	
	BreadthFirstSearch(long long int H,long long int W){
			MaxH=H;
			MaxW=W;
			HW= new char*[H];
			Used= new long long int*[H];
			BFSResult= new long long int*[H];
			for(int i=0;i<H;i++)
			{
					HW[i]= new char[W];
					Used[i]= new long long int[W];
					BFSResult[i]= new long long int[W];
			}
	}
	
	void DoBFS(pair<long long int,long long int>Start){
		for(int i=0;i<MaxH;i++)
		{
			for(int j=0;j<MaxW;j++)
			{
				Used[i][j]=0;
				BFSResult[i][j]=INF;
			}
		}
		Black=false;
		White=false;
		Counter=0;
		queue<pair<long long int,long long int> >task;
		task.push(Start);
		Used[Start.first][Start.second]=1;
		
		while(!task.empty())
		{
			Counter++;
			long long int h=task.front().first;
			long long int w=task.front().second;
			for(int i=-1;i<=1;i++)
			{
				for(int j=-1;j<=1;j++)
				{
					if(h+i<0||w+j<0||h+i>=MaxH||w+j>=MaxW||i!=0&&j!=0)
					{
							continue;
					}
					if(Used[h+i][w+j]==0&&HW[h+i][w+j]=='.')
					{
							Used[h+i][w+j]=1;
							BFSResult[h+i][w+j]=BFSResult[h][w]+1;
							task.push({h+i,w+j});
					}else if(Used[h+i][w+j]==0&&HW[h+i][w+j]=='B'){
						Black=true;
					}else if(Used[h+i][w+j]==0&&HW[h+i][w+j]=='W'){
						White=true;
					}
				}
			}
			task.pop();
		}
	}
	
	void RootCheck(pair<long long int,long long int>Goal){
		pair<long long int,long long int>now=Goal;
		while(!Root.empty()){
			Root.pop();
		}
		Root.push(Goal);
		while(BFSResult[now.first][now.second]!=0)
		{
			bool key=false;
			for(int i=-1;i<=1;i++)
			{
				for(int j=-1;j<=1;j++)
				{
					if(now.first+i<0||now.second+j<0||now.first+i>=MaxH||now.second+j>=MaxW||i!=0&&j!=0)
					{
						continue;
					}
					if(BFSResult[now.first+i][now.second+j]==BFSResult[now.first][now.second]-1&&HW[now.first+i][now.second+j]=='.')
					{
						Root.push({now.first+i,now.second+j});
						key=true;
						now={now.first+i,now.second+j};
						break;
					}
				}
				if(key)
				{
					break;
				}
			}
		}
	}
        
};


int main() {
	cout << fixed << setprecision(18);
	long long int H,W,Counter=0;
	cin>>W>>H;
	while(H!=0){
		long long int Bl=0,Wh=0;
		char resmap[51][51];
		BreadthFirstSearch bfs(H,W);
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>bfs.HW[i][j];
				if(bfs.HW[i][j]=='.'){Counter++;}
				resmap[i][j]=bfs.HW[i][j];
			}
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(bfs.HW[i][j]=='.'){
					bfs.DoBFS({i,j});
					if(bfs.Counter!=Counter||true){
						if(bfs.Black&&!bfs.White){Bl++;resmap[i][j]='p';}
						if(bfs.White&&!bfs.Black){Wh++;resmap[i][j]='q';}
					}
				}
			}
		}
		cout<<Bl<<" "<<Wh<<endl;
		cin>>W>>H;
	}
	
} 


Measured memory_bytes: 4140