#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    char map[h][w];
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        cin >> map[i][j];
      }
    }
    queue<pair<int, int> > a;
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        if (map[i][j] == 'B' || map[i][j] == 'W') {
          if (i > 0) {
            if (map[i - 1][j] == '.') {
              map[i - 1][j] = tolower(map[i][j]);
              a.push(pair<int, int>(i - 1, j));
            } else if (map[i - 1][j] != 'W' && map[i - 1][j] != 'B' &&
                       map[i - 1][j] != 'x' &&
                       map[i - 1][j] != tolower(map[i][j])) {
              map[i - 1][j] = 'x';
              a.push(pair<int, int>(i - 1, j));
            }
          }
          if (i < h - 1) {
            if (map[i + 1][j] == '.') {
              map[i + 1][j] = tolower(map[i][j]);
              a.push(pair<int, int>(i + 1, j));
            } else if (map[i + 1][j] != 'W' && map[i + 1][j] != 'B' &&
                       map[i + 1][j] != 'x' &&
                       map[i + 1][j] != tolower(map[i][j])) {
              map[i + 1][j] = 'x';
              a.push(pair<int, int>(i + 1, j));
            }
          }
          if (j > 0) {
            if (map[i][j - 1] == '.') {
              map[i][j - 1] = tolower(map[i][j]);
              a.push(pair<int, int>(i, j - 1));
            } else if (map[i][j - 1] != 'W' && map[i][j - 1] != 'B' &&
                       map[i][j - 1] != 'x' &&
                       map[i][j - 1] != tolower(map[i][j])) {
              map[i][j - 1] = 'x';
              a.push(pair<int, int>(i, j - 1));
            }
          }
          if (j < w - 1) {
            if (map[i][j + 1] == '.') {
              map[i][j + 1] = tolower(map[i][j]);
              a.push(pair<int, int>(i, j + 1));
            } else if (map[i][j + 1] != 'W' && map[i][j + 1] != 'B' &&
                       map[i][j + 1] != 'x' &&
                       map[i][j + 1] != tolower(map[i][j])) {
              map[i][j + 1] = 'x';
              a.push(pair<int, int>(i, j + 1));
            }
          }
        }
      }
    }
    while (!a.empty()) {
      int x, y;
      x = a.front().first;
      y = a.front().second;
      a.pop();
      if (x > 0) {
        if (map[x][y] == 'b') {
          if (map[x - 1][y] == 'w' || map[x - 1][y] == 'x') {
            map[x][y] = map[x - 1][y] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x - 1, y));
          } else if (map[x - 1][y] == '.') {
            map[x - 1][y] = 'b';
            a.push(pair<int, int>(x - 1, y));
          } else if (map[x - 1][y] == 'W') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else if (map[x][y] == 'w') {
          if (map[x - 1][y] == 'b' || map[x - 1][y] == 'x') {
            map[x][y] = map[x - 1][y] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x - 1, y));
          } else if (map[x - 1][y] == '.') {
            map[x - 1][y] = 'w';
            a.push(pair<int, int>(x - 1, y));
          } else if (map[x - 1][y] == 'B') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else {
          if (map[x - 1][y] != 'B' && map[x - 1][y] != 'W' &&
              map[x - 1][y] != 'x') {
            map[x - 1][y] = 'x';
            a.push(pair<int, int>(x - 1, y));
          }
        }
      }
      if (x < h - 1) {
        if (map[x][y] == 'b') {
          if (map[x + 1][y] == 'w' || map[x + 1][y] == 'x') {
            map[x][y] = map[x + 1][y] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x + 1, y));
          } else if (map[x + 1][y] == '.') {
            map[x + 1][y] = 'b';
            a.push(pair<int, int>(x + 1, y));
          } else if (map[x - 1][y] == 'W') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else if (map[x][y] == 'w') {
          if (map[x + 1][y] == 'b' || map[x + 1][y] == 'x') {
            map[x][y] = map[x + 1][y] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x + 1, y));
          } else if (map[x + 1][y] == '.') {
            map[x + 1][y] = 'w';
            a.push(pair<int, int>(x + 1, y));
          } else if (map[x - 1][y] == 'B') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else {
          if (map[x + 1][y] != 'B' && map[x + 1][y] != 'W' &&
              map[x + 1][y] != 'x') {
            map[x + 1][y] = 'x';
            a.push(pair<int, int>(x + 1, y));
          }
        }
      }
      if (y > 0) {
        if (map[x][y] == 'b') {
          if (map[x][y - 1] == 'w' || map[x][y - 1] == 'x') {
            map[x][y] = map[x][y - 1] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x, y - 1));
          } else if (map[x][y - 1] == '.') {
            map[x][y - 1] = 'b';
            a.push(pair<int, int>(x, y - 1));
          } else if (map[x - 1][y] == 'W') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else if (map[x][y] == 'w') {
          if (map[x][y - 1] == 'b' || map[x][y - 1] == 'x') {
            map[x][y] = map[x][y - 1] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x, y - 1));
          } else if (map[x][y - 1] == '.') {
            map[x][y - 1] = 'w';
            a.push(pair<int, int>(x, y - 1));
          } else if (map[x - 1][y] == 'B') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else {
          if (map[x][y - 1] != 'B' && map[x][y - 1] != 'W' &&
              map[x][y - 1] != 'x') {
            map[x][y - 1] = 'x';
            a.push(pair<int, int>(x, y - 1));
          }
        }
      }
      if (y < w - 1) {
        if (map[x][y] == 'b') {
          if (map[x][y + 1] == 'w' || map[x][y + 1] == 'x') {
            map[x][y] = map[x][y + 1] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x, y + 1));
          } else if (map[x][y + 1] == '.') {
            map[x][y + 1] = 'b';
            a.push(pair<int, int>(x, y + 1));
          } else if (map[x - 1][y] == 'W') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else if (map[x][y] == 'w') {
          if (map[x][y + 1] == 'b' || map[x][y + 1] == 'x') {
            map[x][y] = map[x][y + 1] = 'x';
            a.push(pair<int, int>(x, y));
            a.push(pair<int, int>(x, y + 1));
          } else if (map[x][y + 1] == '.') {
            map[x][y + 1] = 'w';
            a.push(pair<int, int>(x, y + 1));
          } else if (map[x - 1][y] == 'B') {
            map[x][y] = x;
            a.push(pair<int, int>(x, y));
          }
        } else {
          if (map[x][y + 1] != 'B' && map[x][y + 1] != 'W' &&
              map[x][y + 1] != 'x') {
            map[x][y + 1] = 'x';
            a.push(pair<int, int>(x, y + 1));
          }
        }
      }
    }
    pair<int, int> ans;
    ans.first = ans.second = 0;
    for (int i = 0; i < (h); i++) {
      for (int j = 0; j < (w); j++) {
        cout << map[i][j];
        if (map[i][j] == 'b')
          ans.first++;
        else if (map[i][j] == 'w')
          ans.second++;
      }
      cout << endl;
    }
    cout << ans.first << " " << ans.second << endl;
  }
}
