#include <iostream>
using namespace std;

int w,h,cntW,cntB;
char map[51][51],mapW[51][51],mapB[51][51];


void visitB(int i, int j){
  mapB[i][j] = 'B';
  if( i+1 <= h && mapB[i+1][j] == '.' )visitB(i+1,j);
  if( i-1 >= 0 && mapB[i-1][j] == '.')visitB(i-1,j);
  if( j+1 <= w && mapB[i][j+1] == '.')visitB(i,j+1);
  if( j-1 >= 0 && mapB[i][j-1] == '.')visitB(i,j-1);
}

void visitW(int i, int j){
  mapW[i][j] = 'W';
  if( i+1 <= h && mapW[i+1][j] == '.' )visitW(i+1,j);
  if( i-1 >= 0 && mapW[i-1][j] == '.')visitW(i-1,j);
  if( j+1 <= w && mapW[i][j+1] == '.')visitW(i,j+1);
  if( j-1 >= 0 && mapW[i][j-1] == '.')visitW(i,j-1);
}



int main(){
  while(1){
    int i,j;
    cin >> w >> h;
    if ( w == 0 && h == 0 ) break;
    cntB = 0,cntW = 0;
    for( i = 1; i <= h; i++ ){
      for ( j = 1; j <=w; j++ ){
	cin >> map[i][j];
	mapW[i][j] = map[i][j];
	mapB[i][j] = map[i][j];
      }
    }

      
    for( i = 1; i <= h; i++ ){
      for( j = 1; j <= w; j++ ){
	if( mapB[i][j] == 'B' ){
	  visitB(i,j);
	}
      }
    }
    
    for( i = 1; i <= h; i++ ){
      for( j = 1; j <= w; j++ ){
	if( mapW[i][j] == 'W' ){
	  visitW(i,j);
	}
      }
    }
        
    for( i = 1; i <=h; i++ ){
      for( j = 1; j <= w; j++ ){
	if(map[i][j] == '.' ){
	  if( mapB[i][j] == 'B' && mapW[i][j] == 'W' ) continue;
	  else if( mapB[i][j] == 'B' ) cntB++;
	  else if( mapW[i][j] == 'W' ) cntW++;
	  }
	}
      }
    
    cout << cntB << " " << cntW << endl;
  }
  
  return 0;
}