#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double eps = 1e-10;
const double pi = acos(-1.0);
const long long INF = 1LL << 62;
const int inf = 1 << 29;
int w, h;
vector<string> m;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
void dfs(char tar, pair<int, int> p);
int main(void) {
  for (; cin >> w >> h, w;) {
    m = vector<string>(h);
    for (int y = (0); y < (h); ++y) cin >> m[y];
    for (int y = (0); y < (h); ++y)
      for (int x = (0); x < (w); ++x)
        if (m[y][x] == 'B') {
          for (int i = (0); i < (4); ++i) {
            dfs('B', make_pair(x + dx[i], y + dy[i]));
          }
        }
    for (int y = (0); y < (h); ++y)
      for (int x = (0); x < (w); ++x)
        if (m[y][x] == 'W') {
          for (int i = (0); i < (4); ++i) {
            dfs('W', make_pair(x + dx[i], y + dy[i]));
          }
        }
    for (int y = (0); y < (h); ++y) {
      for (int x = (0); x < (w); ++x) {
        cout << m[y][x] << " ";
      }
      cout << endl;
    }
    pair<int, int> sum = make_pair(0, 0);
    for (int y = (0); y < (h); ++y)
      sum.first += count((m[y]).begin(), (m[y]).end(), 'b');
    for (int y = (0); y < (h); ++y)
      sum.second += count((m[y]).begin(), (m[y]).end(), 'w');
    cout << sum.first << " " << sum.second << endl;
  }
  return 0;
}
void dfs(char tar, pair<int, int> p) {
  if (p.first < 0 || w <= p.first || p.second < 0 || h <= p.second) return;
  char ene = tar == 'B' ? 'W' : 'B';
  char extar = tar == 'B' ? 'b' : 'w';
  char exene = tar == 'B' ? 'w' : 'b';
  if (m[p.second][p.first] == ene || m[p.second][p.first] == extar ||
      m[p.second][p.first] == '-' || m[p.second][p.first] == tar)
    return;
  if (m[p.second][p.first] == '.') m[p.second][p.first] = extar;
  if (m[p.second][p.first] == exene) m[p.second][p.first] = '-';
  for (int i = (0); i < (4); ++i) {
    dfs(tar, make_pair(p.first + dx[i], p.second + dy[i]));
  }
}
