#include <iostream>
#include <map>
#include <cstring>
using namespace std;

int w, h;
char mas[50][50];
int vb[50][50], vw[50][50];

map< char, int > c;

static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void rec(int y, int x, int color) {
    if(!(0 <= x && x < w && 0 <= y && y < h)) return;
    if(color != c[mas[y][x]] && mas[y][x] != '.') return;
    if((!color && vb[y][x]) || (color && vw[y][x])) return;
    if(color) vw[y][x] = 1;
    else vb[y][x] = 1;

    for(int i = 0; i < 4; i++) {
        rec(y + dy[i], x + dx[i], color);
    }
}

int main() {

    c['B'] = 0, c['W'] = 1, c['.'] = -1;

    while(cin >> w >> h, w) {
        memset(vb, 0, sizeof(vb));
        memset(vw, 0, sizeof(vw));
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                cin >> mas[i][j];
            }
        }

        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(mas[i][j] == 'B' && !vb[i][j]) rec(i, j, 0);
                if(mas[i][j] == 'W' && !vw[i][j]) rec(i, j, 1);
            }
        }

        int sumb = 0, sumw = 0;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(vb[i][j] ^ vw[i][j] && mas[i][j] == '.') {
                    if(vb[i][j]) sumb++;
                    else sumw++;
                }
            }
        }

        cout << sumb << " " << sumw << endl;
    }
}

