#include <bits/stdc++.h>
using namespace std;
int dxy[4] = {-1, 1, 0, 0};
int W, H;
char a[60][60];
int temp[60][60];
int huga(int x, int y) {
  int w = 0, b = 0, s = 0, ans = -3, t;
  vector<vector<int>> z;
  z = vector<vector<int>>(H + 1, vector<int>(W + 1, 0));
  queue<pair<int, int>> Q;
  Q.push(pair<int, int>(y, x));
  while (!Q.empty()) {
    pair<int, int> p = Q.front();
    Q.pop();
    int yy = p.first, xx = p.second;
    z[yy][xx] = 1;
    for (int i = 0; i <= 3; i++) {
      int nx = xx + dxy[i], ny = yy + dxy[3 - i];
      if (temp[ny][nx] == -1) return -1;
    }
    for (int i = 0; i <= 3; i++) {
      int nx = xx + dxy[i], ny = yy + dxy[3 - i];
      if (a[ny][nx] == '.' && !z[ny][nx])
        Q.push(pair<int, int>(ny, nx));
      else if (a[ny][nx] == 'B')
        b = 1;
      else if (a[ny][nx] == 'W')
        w = 1;
      if (b && w) return ans = -1;
    }
  }
  if (w && b || !w && !b)
    ans = -1;
  else if (!w && b)
    ans = 1;
  else if (!b && w)
    ans = 0;
  else
    ans = -4;
  return ans;
}
int main() {
  while (1) {
    int cw = 0, cb = 0;
    cin >> W >> H;
    if (!W && !H) break;
    for (int i = 0; i <= W + 1; i++) {
      a[0][i] = a[H + 1][i] = 0;
      temp[H + 1][i] = temp[0][i] = 2;
    }
    for (int i = 0; i <= H + 1; i++) {
      a[i][0] = a[i][W + 1] = 0;
      temp[i][0] = temp[0][i] = 2;
    }
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        cin >> a[i][j];
        temp[i][j] = 2;
      }
    }
    for (int i = 1; i <= H; i++) {
      for (int j = 1; j <= W; j++) {
        if (a[i][j] == '.') {
          temp[i][j] = huga(j, i);
          if (temp[i][j] == 1)
            a[i][j] == 'B';
          else if (temp[i][j] == 0)
            a[i][j] == 'W';
          if (temp[i][j] == 1)
            cb++;
          else if (temp[i][j] == 0)
            cw++;
        }
      }
    }
    cout << cb << " " << cw << endl;
  }
  return 0;
}
