#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int dfs(char color, char enemyColor, vector<vector<char>> &field, vector<vector<int>> &cells, vector<pair<int, int>> &st, int y, int x) {
    st.push_back({y, x});
    cells[y][x] = 0;
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};

    int ret = 2;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (field[ny][nx] == enemyColor) {
            ret = 0;
        }
        if (field[ny][nx] == '.' && cells[ny][nx] == -1) {
            ret = min(dfs(color, enemyColor, field, cells, st, ny, nx), ret);
        }
        if (field[ny][nx] == color) {
            ret = min(ret, 1);
        }
    }
    return ret;
}

pair<int, int> solve(int W, int H) {
    int ansBlack = 0;
    int ansWhite = 0;
    vector<vector<char>> field(H+2, vector<char>(W+2, '#'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> field[i][j];
        }
    }

    vector<vector<int>> blackCells(H+2, vector<int>(W+2, -1));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (blackCells[i][j] == -1 && field[i][j] == '.') {
                vector<pair<int, int>> st;
                int flag = dfs('B', 'W', field, blackCells, st, i, j);
                for (auto &p : st) {
                    blackCells[p.first][p.second] = flag;
                }
            }
        }
    }

    vector<vector<int>> whiteCells(H+2, vector<int>(W+2, -1));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (whiteCells[i][j] == -1 && field[i][j] == '.') {
                vector<pair<int, int>> st;
                int flag = dfs('W', 'B', field, whiteCells, st, i, j);
                for (auto &p : st) {
                    whiteCells[p.first][p.second] = flag;
                }
            }
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (blackCells[i][j] == 1) {
                ansBlack++;
            }
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (whiteCells[i][j] == 1) {
                ansWhite++;
            }
        }
    }
    return {ansBlack, ansWhite};
}

int main(void) {
    int W, H;
    vector<pair<int, int>> ans;
    while (1) {
        cin >> W >> H;
        if (!W && !H) break;
        ans.push_back(solve(W, H));
    }
    for (auto &i : ans) {
        cout << i.first << " " << i.second << endl;
    }
}   


Measured memory_bytes: 3560