#include<iostream>
#include<string>
using namespace std;
#define MAX 52
bool dfs(char map[MAX][MAX], int i, int j, int h, int w, char &c){
  const int di[] = {-1,0,1,0};
  const int dj[] = {0,1,0,-1};

  if( i < 1 || i > h || j < 1 || j > w )
    return true;

  if( map[i][j] == 'V' )
    return true;

  //cout << '(' << i << ',' << j << ')' << ' ';

  if( map[i][j] == 'B' || map[i][j] == 'W' ){
    if( (c == 'B' || c == 'W') && map[i][j] != c ){
      return false;
    }else{
      c = map[i][j];
      //cout << c << endl;
      return true;
    }
  }

  map[i][j] = 'V';
  for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
    if( !dfs( map, i + di[k], j + dj[k], h, w, c ) )
      return false;
  }
  return true;
}
int main(){
  while(true){
    int w,h;
    int numBlack = 0, numWhite = 0;
    char o_map[MAX][MAX], map[MAX][MAX];
    cin>>w>>h;
    if(w==0&&h==0)break;
    for(int i = 0; i < h; ++i){
      string s;
      cin >> s;
      for(unsigned int j = 0; j < w; ++j){
	o_map[i+1][j+1] = map[i+1][j+1] = s[j];
      }
    }
    for(int i = 1; i <= h; ++i){
      for(int j = 1; j <= w; ++j){
	char c = 'V';
	if( map[i][j] == '.' ){
	  if( dfs( map, i, j, h, w, c ) ){
	    if( c == 'B' )
	      ++numBlack;
	    if( c == 'W' )
	      ++numWhite;
	  }
	  for(int y = 1; y <= h; ++y){
	    for(int x = 1; x <= w; ++x){
	      //cout << map[y][x];
	      map[y][x] = o_map[y][x];
	    }
	    //cout << endl;
	  }
	}
      }
    }
    cout << numBlack << ' ' << numWhite << endl;
  }
  return 0;
}