#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<b;++i)
char c[60][60];
int a[60][60];
int flag, w, h;

void dfs(int y,int x){
  if(c[y][x] == 'B'){
    if(flag == 0 || flag == 1) flag = 1;
    else flag = 3;    
    a[y][x] = 9;
  }else if(c[y][x] == 'W'){
    if(flag == 0 || flag == 2) flag = 2;
    else flag = 3;
    a[y][x] = 9;
  }else if(a[y][x]==0){
    a[y][x] = 4;
    FOR(i,y-1,y+2) if(i>=0 && i<h) dfs(i,x);
    FOR(j,x-1,x+2) if(j>=0 && j<w) dfs(y,j);
  }
}
int main(){
  int bl, wh;
  while(cin>>w>>h, w){
    bl = 0; wh = 0;
    REP(i, h) REP(j, w){
      cin>>c[i][j];
      a[i][j]=0;
    }
    
    REP(i, h) REP(j, w){
      if(c[i][j] == 'B' || c[i][j] == 'W' || a[i][j]) continue;
      flag = 0;
      dfs(i,j);
      
      if(flag) REP(k,h) REP(l,w){
          if(a[k][l] == 4) a[k][l] = flag;
        }
    }
    REP(i,h) REP(j,w){
      if(a[i][j] == 1) bl++;
      if(a[i][j] == 2) wh++;
    }
    cout<<bl<<" "<<wh<<endl;
  }
  return 0;
}