#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define ck(a,b) (0<=(a)&&(a)<b)
using namespace std;
int dx[]={-1,1,0,0},dy[]={0,0,-1,1};
char land[60][60];
int w,h;
int cked[2][60][60],own[2][60][60];
int ad(int y,int x,int c){
	cked[c][y][x]=1;
	int r=0,ny,nx;
	rep(d,4){
		ny=y+dy[d],nx=x+dx[d];
		if(!ck(ny,h)||!ck(nx,w)||cked[c][ny][nx])continue;
		if(land[ny][nx]==(c?'W':'B'))return 1;
	}
	rep(d,4){
		ny=y+dy[d],nx=x+dx[d];
		if(!ck(ny,h)||!ck(nx,w)||cked[c][ny][nx])continue;
		if(land[ny][nx]=='.')r=r||ad(ny,nx,c);
		if(r)return 1;
	}
	return r;
}
void fl(int y,int x,int c){
	own[c][y][x]=1;
	rep(d,4){
		int ny=y+dy[d],nx=x+dx[d];
		if(ck(ny,h)&&ck(nx,w)&&!own[c][ny][nx]&&land[ny][nx]=='.')fl(ny,nx,c);
	}
}
int main(){
	while(cin>>w>>h,w){
		rep(i,h)cin>>land[i];
		rep(i,h)rep(j,w)rep(k,2)cked[k][i][j]=own[k][i][j]=0;
		rep(i,h)rep(j,w)rep(k,2)
		if(!cked[k][i][j]&&land[i][j]=='.')if(ad(i,j,k))fl(i,j,k);
		int ans[2]={0};
		rep(i,h)rep(j,w)if(own[0][i][j]+own[1][i][j]==1)ans[own[0][i][j]]++;
		cout<<ans[1]<<" "<<ans[0]<<endl;
	}
	return 0;
}