#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int w,h;
int black[51][51];
int white[51][51];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char map[51][51];
void solve(int y,int x,char c){
    if((c == 'B' && black[y][x]) || (c == 'W' && white[y][x])) return;
    if(c == 'W' && map[y][x]!='W') white[y][x] = 1;
    else if(c == 'B' && map[y][x]!='B') black[y][x] = 1;
    
    rep(i, 4){
        int nx = x + dx[i]; int ny = y + dy[i];
        if(0 <= nx && nx < w && 0 <= ny && ny < h && map[ny][nx] == '.'){
            solve(ny, nx, c);
        }
    }
}
int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        getchar();
        rep(i,h) scanf("%s",map[i]);
        rep(i,h){
            rep(j,w){
                black[i][j]=white[i][j]=0;
            }
        }
        rep(i,h){
            rep(j,w){
                if(map[i][j]=='W'){
                    solve(i,j,'W');
                }else if(map[i][j]=='B'){
                    solve(i,j,'B');
                }
            }
        }
        int bl=0,wh=0;
        rep(i,h){
            rep(j,w){
                if(black[i][j] && !white[i][j]) bl++;
                else if(!black[i][j] && white[i][j]) wh++;
            }
        }
        printf("%d %d\n",bl,wh);
    }
}

