#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int, int>;

int h, w, bl, wh;
string a[55];
int d[] = {0, 1, 0, -1};

void solve();
bool ch(p now);

int main() {
  while(1) {
    cin >> w >> h;
    if(w + h == 0) break;
    for(int i = 0; i < h; ++i) cin >> a[i];
    solve();
    cout << bl << " " << wh << endl;
  }

  return 0;
}

void solve() {
  bl = wh = 0;
  vector<vector<int>> v;
  queue<p> qu[2];
  v.resize(h);
  for(int i = 0; i < h; ++i) v[i].assign(w, 0);
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      if(a[i][j] == 'B') { qu[0].push({i, j}); }
      if(a[i][j] == 'W') { qu[1].push({i, j}); }
    }
  for(int t = 0; t < 2; ++t) {
    while(qu[t].size() > 0) {
      p now = qu[t].front();
      qu[t].pop();
      for(int i = 0; i < 4; ++i) {
        p nextp = now;
        nextp.fi += d[i];
        nextp.se += d[i ^ 1];
        if(!ch(nextp)) continue;
        if((v[nextp.fi][nextp.se] & (t + 1)) != (t + 1) &&
           a[nextp.fi][nextp.se] == '.') {
          v[nextp.fi][nextp.se] += (t + 1);
          qu[t].push(nextp);
        }
      }
    }
  }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      bl += (v[i][j] == 1);
      wh += (v[i][j] == 2);
    }
}

bool ch(p now) {
  return now.fi >= 0 && now.fi < h && now.se >= 0 &&
         now.se < w;
}
