#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

bool B[50][50], W[50][50], used[50][50];
char a[50][50];
int w, h;

void dfs(int y, int x, bool flag) {
    if (y < 0 || h <= y || x < 0 || w <= x) return;

    if (a[y][x] == '.') (flag ? B[y][x] : W[y][x]) = true;

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

    rep (i, 4) rep (j, 4) {
        int toy = y + dy[i], tox = x + dx[i];
        if (toy < 0 || h <= toy || tox < 0 || w <= tox) continue;
        if (used[toy][tox] || a[toy][tox] != '.') continue;
        used[toy][tox] = true;
        dfs(toy, tox, flag);
    }
}

int main() {
    while (cin >> w >> h, w) {
        rep (i, h) rep (j, w) cin >> a[i][j];

        rep (i, h) rep (j, w) used[i][j] = false, B[i][j] = false;
        rep (i, h) rep (j, w) if (! used[i][j]) if (a[i][j] == 'B') {
            used[i][j] = true;
            dfs(i, j, true);
        }

        rep (i, h) rep (j, w) used[i][j] = false, W[i][j] = false;
        rep (i, h) rep (j, w) if (! used[i][j]) if (a[i][j] == 'W') {
            used[i][j] = true;
            dfs(i, j, false);
        }

        int cntB = 0, cntW = 0;
        rep (i, h) rep (j, w) {
            cntB += (B[i][j] && ! W[i][j]);
            cntW += (! B[i][j] && W[i][j]);
        }
        cout << cntB << " " << cntW << endl;
    }
    return 0;
}
