import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	while (1) {
		auto x = readln.chomp.split.map!(to!int);
		if (!x[0]) break;
		auto area = new char[][](x[1], x[0]);
		foreach (i; 0..x[1]) {
			area[i] = readln.chomp.map!(to!char).array;
		}
		int num[2];
		auto hu = ['W', 'B'];

		void solve(int i, int j, int type) {
			if (area[i][j] == '.') {
				num[type]++;
				area[i][j] = (hu[type] + 32).to!char;
			} else if (area[i][j] == hu[!type] + 32) {
				num[(!type).to!int]--;
				area[i][j] = 'd';
			}
			foreach (a; iota(-1, 2, 2)) {
				if (i + a >= 0 && i + a < x[1]) {
					if (area[i+a][j] != 'W' && area[i+a][j] != 'B' && area[i+a][j] != (hu[type] + 32).to!char && area[i+a][j] != 'd') {
						solve(i + a, j, type);
					}
				}
				if (j + a >= 0 && j + a < x[0]) {
					if (area[i][j+a] != 'W' && area[i][j+a] != 'B' && area[i][j+a] != (hu[type] + 32).to!char && area[i][j+a] != 'd') {
						solve(i, j + a, type);
					}
				}
			}
		}

		foreach (i; 0..x[1]) {
			foreach (j; 0..x[0]) {
				if (area[i][j] != 'W' && area[i][j] != 'B') continue;
				if (area[i][j] == 'W') solve(i, j, 0);
				else solve(i, j, 1);
			}
		}
		writeln(num[1], " ", num[0]);
	}
}