#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
struct lattice {
  bool wallB, wallW, black, white;
};
struct zahyou {
  int x;
  int y;
};
int main() {
  vector<int> ans_B, ans_W;
  while (1) {
    int w, h;
    char a;
    cin >> w >> h;
    if (!w && !h) break;
    vector<vector<lattice> > v(h + 2);
    for (int i = 1; i <= h; i++) {
      vector<lattice> q(w + 2);
      lattice l;
      l.wallB = 1;
      l.wallW = 1;
      l.black = 0;
      l.white = 0;
      q[0] = l;
      q[w + 1] = l;
      for (int j = 1; j <= w; j++) {
        cin >> a;
        l.wallB = 0;
        l.wallW = 0;
        l.black = 0;
        l.white = 0;
        if (a == 'W') l.wallW = 1;
        if (a == 'B') l.wallB = 1;
        q[j] = l;
      }
      v[i] = q;
    }
    for (int j = 0; j <= w + 1; j++) {
      lattice l;
      l.wallB = 1;
      l.wallW = 1;
      l.black = 0;
      l.white = 0;
      v[0].push_back(l);
      v[h + 1].push_back(l);
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (v[i][j].wallW) {
          queue<zahyou> que;
          zahyou z;
          z.x = i;
          z.y = j;
          que.push(z);
          while (que.size()) {
            printf("%d , %d", que.front().x, que.front().y);
            for (int k = 0; k < 4; k++) {
              if (1 <= que.front().x && que.front().x <= h &&
                  1 <= que.front().y && que.front().y <= w) {
                if (!v[que.front().x + dx[k]][que.front().y + dy[k]].white &&
                    !v[que.front().x + dx[k]][que.front().y + dy[k]].wallB &&
                    !v[que.front().x + dx[k]][que.front().y + dy[k]].wallW) {
                  z.x = que.front().x + dx[k];
                  z.y = que.front().y + dy[k];
                  que.push(z);
                  v[que.front().x + dx[k]][que.front().y + dy[k]].white = 1;
                }
              }
            }
            que.pop();
          }
        }
        if (v[i][j].wallB) {
          queue<zahyou> que;
          zahyou z;
          z.x = i;
          z.y = j;
          que.push(z);
          while (que.size()) {
            printf("%d , %d", que.front().x, que.front().y);
            for (int k = 0; k < 4; k++) {
              if (1 <= que.front().x && que.front().x <= h &&
                  1 <= que.front().y && que.front().y <= w) {
                if (!v[que.front().x + dx[k]][que.front().y + dy[k]].black &&
                    !v[que.front().x + dx[k]][que.front().y + dy[k]].wallB &&
                    !v[que.front().x + dx[k]][que.front().y + dy[k]].wallW) {
                  z.x = que.front().x + dx[k];
                  z.y = que.front().y + dy[k];
                  que.push(z);
                  v[que.front().x + dx[k]][que.front().y + dy[k]].black = 1;
                }
              }
            }
            que.pop();
          }
        }
      }
    }
    int countB = 0, countW = 0;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (v[i][j].black && v[i][j].white) {
        } else if (v[i][j].black && !v[i][j].wallB && !v[i][j].wallW) {
          countB++;
        } else if (v[i][j].white && !v[i][j].wallB && !v[i][j].wallW) {
          countW++;
        }
      }
    }
    ans_B.push_back(countB);
    ans_W.push_back(countW);
  }
  for (int i = 0; i < ans_B.size(); i++)
    cout << ans_B[i] << " " << ans_W[i] << endl;
}
