#include <bits/stdc++.h>
using namespace std;
int w, h;
string f[51];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void solve(int x, int y, char c) {
  char c_, r;
  if (c == 'W') {
    c_ = 'w';
    r = 'B';
  }
  if (c == 'B') {
    c_ = 'b';
    r = 'W';
  }
  for (int i = 0; i < 4; ++i) {
    int mx = x + dx[i];
    int my = y + dy[i];
    if (mx < 0 || my < 0 || mx >= w || my >= h) continue;
    if (c == 'W' || c == 'B') {
      if (f[my][mx] == '.') {
        f[my][mx] = c_;
        solve(mx, my, c);
      }
      if (f[my][mx] == r) {
        f[my][mx] = 'x';
        solve(mx, my, 'x');
      }
    } else if (c == 'x') {
      if (f[my][mx] == 'w' || f[my][mx] == 'b' || f[my][mx] == '.') {
        f[my][mx] = 'x';
        solve(mx, my, 'x');
      }
    }
  }
}
void debug() {
  cout << endl;
  for (int y = 0; y < h; ++y) {
    cout << f[y] << endl;
  }
  cout << endl;
}
int main() {
  while (cin >> w >> h, w | h) {
    for (int y = 0; y < h; ++y) {
      cin >> f[y];
    }
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (f[y][x] == 'W') {
          solve(x, y, 'W');
        }
      }
    }
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (f[y][x] == 'B') {
          solve(x, y, 'B');
        }
      }
    }
    int black = 0, white = 0;
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (f[y][x] == 'w') white++;
        if (f[y][x] == 'b') black++;
      }
    }
    cout << black << " " << white << endl;
  }
}
