//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

vector<string> dp(50);
bool now[50][50];

int main(void) {

	while (1) {
		int w, h;
		int black = 0, white = 0;
		queue < pair<int, int> > que;
		pair <int, int> pos;
		pair <int, int>load;

		cin >> w >> h;
		if (w == 0) {
			break;
		}
		FOR(i, 0, 49) {
			dp[i] = "";
		}
		FOR(i, 0, 49) {
			FOR(j, 0, 49) {
				now[i][j] = false;
			}
		}
		FOR(i, 0, h - 1) {
			cin >> dp[i];
		}
		FOR(i, 0, h - 1) {
			FOR(j, 0, w - 1) {
				if (dp[i][j] == '.'&&now[i][j] == false) {
					int count = 1;
					int sta = 0;//no,white,black,double
					que.push(make_pair(i, j));
					while (!que.empty()) {
						pos = que.front();
						que.pop();
						//cout << pos.first << " " << pos.second << " " << count << " " << sta << endl;
						now[pos.first][pos.second] = true;
						if (pos.first + 1 <= h - 1) {
							if (dp[pos.first + 1][pos.second] == '.'&&now[pos.first + 1][pos.second] == false) {
								count++;
								load = make_pair(pos.first + 1, pos.second);
								que.push(load);
								now[pos.first + 1][pos.second] = true;
							}
							if (dp[pos.first + 1][pos.second] == 'B') {
								switch (sta) {
								case 0:
									sta = 2;
									break;
								case 1:
									sta = 3;
									break;
								}
							}
							if (dp[pos.first + 1][pos.second] == 'W') {
								switch (sta) {
								case 0:
									sta = 1;
									break;
								case 2:
									sta = 3;
									break;
								}
							}
						}
						if (pos.first - 1 >= 0) {
							if (dp[pos.first - 1][pos.second] == '.'&&now[pos.first - 1][pos.second] == false) {
								count++;
								load = make_pair(pos.first - 1, pos.second);
								que.push(load);
								now[pos.first - 1][pos.second] = true;
							}
							if (dp[pos.first - 1][pos.second] == 'B') {
								switch (sta) {
								case 0:
									sta = 2;
									break;
								case 1:
									sta = 3;
									break;
								}
							}
							if (dp[pos.first - 1][pos.second] == 'W') {
								switch (sta) {
								case 0:
									sta = 1;
									break;
								case 2:
									sta = 3;
									break;
								}
							}
						}
						if (pos.second + 1 <= w - 1) {
							if (dp[pos.first][pos.second + 1] == '.'&&now[pos.first][pos.second + 1] == false) {
								count++;
								load = make_pair(pos.first, pos.second + 1);
								que.push(load);
								now[pos.first][pos.second + 1] = true;
							}
							if (dp[pos.first][pos.second + 1] == 'B') {
								switch (sta) {
								case 0:
									sta = 2;
									break;
								case 1:
									sta = 3;
									break;
								}
							}
							if (dp[pos.first][pos.second + 1] == 'W') {
								switch (sta) {
								case 0:
									sta = 1;
									break;
								case 2:
									sta = 3;
									break;
								}
							}
						}
						if (pos.second - 1 >= 0) {
							if (dp[pos.first][pos.second - 1] == '.'&&now[pos.first][pos.second - 1] == false) {
								count++;
								load = make_pair(pos.first, pos.second - 1);
								que.push(load);
								now[pos.first][pos.second - 1] = true;
							}
							if (dp[pos.first][pos.second - 1] == 'B') {
								switch (sta) {
								case 0:
									sta = 2;
									break;
								case 1:
									sta = 3;
									break;
								}
							}
							if (dp[pos.first][pos.second - 1] == 'W') {
								switch (sta) {
								case 0:
									sta = 1;
									break;
								case 2:
									sta = 3;
									break;
								}
							}
						}
					}
					switch (sta) {
					case 1:
						white += count;
						break;
					case 2:
						black += count;
						break;
					}
				}
			}
		}
		cout << black << " " << white << endl;
	}

	return 0;
}


Measured memory_bytes: 3032