#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)

int dp[60][60];
char a[60][60];
//1 null 2 B 3 W 4 non
void calc(int w,int h){
  queue<tuple<int,int,int>> task;
  task.push(make_tuple(1,1,1));
  while(!task.empty()){
    tuple<int,int,int>memo =task.front();
    task.pop();
    int x,y,stat;
    x=get<0>(memo);
    y=get<1>(memo);
    stat=get<2>(memo);
    if(dp[x][y]==stat||dp[x][y]==4) continue;
    if(dp[x][y]>1&&stat==1) continue;
    if(dp[x][y]==2&&stat==3||dp[x][y]==3&&stat==2) stat=4;
    if(a[x][y]!='.'&&stat==4) continue;
    if(a[x][y]=='W') stat=3;
    if(a[x][y]=='B') stat=2;
    if(a[x][y]=='!') continue;
    dp[x][y]=stat;
    task.push(make_tuple(x+1,y,stat));
    task.push(make_tuple(x-1,y,stat));
    task.push(make_tuple(x,y+1,stat));
    task.push(make_tuple(x,y-1,stat));
  }

  return;
}
int main(){
  while(1){
    int w,h;
    cin>>w>>h;
    if(w==0&&h==0) break;
    lp(i,60){
      lp(j,60){
	dp[i][j]=0;
	a[i][j]='!';
      }
    }
    lp(i,h+1){
      if(i==0) continue;
      lp(j,w+1){
	if(j==0) continue;
	cin>>a[j][i];
      }
    }
    calc(w,h);
    int countb=0,countw=0;
    lp(i,h+1){
      if(i==0) continue;
      lp(j,w+1){
	if(j==0) continue;
	if(a[j][i]=='.'){
	  if(dp[j][i]==2) countb++;
	  if(dp[j][i]==3) countw++;
	}
      }
    }
    cout<<countb<<" "<<countw<<endl;
    
  }
  return 0;
}


