#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int w, h;
void dfs(int y, int x, char c, vector<string> &vs) {
  if(y < 0 || y >= h || x < 0 || x >= w) return;
  if(vs[y][x] == 'W' || vs[y][x] == 'B') return;
  if(vs[y][x] == c || vs[y][x] == '3') return;
  if(vs[y][x] == '.') vs[y][x] = c;
  else if(vs[y][x] != c) vs[y][x] = '3';
  dfs(y+1,x,c,vs);
  dfs(y-1,x,c,vs);
  dfs(y,x+1,c,vs);
  dfs(y,x-1,c,vs);
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  while(cin>>w>>h,w||h) {
    vector<string> vs(h);
    FOR(i,0,h) cin >> vs[i];
    FOR(y,0,h) {
      FOR(x,0,w) {
        if(vs[y][x] == 'W' || vs[y][x] == 'B') {
          dfs(y + 1, x, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y - 1, x, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y, x + 1, vs[y][x] == 'B' ? '1' : '2', vs);
          dfs(y, x - 1, vs[y][x] == 'B' ? '1' : '2', vs);
        }
      }
    }
    int ans[2]; CLR(ans);
    FOR(y,0,h) {
      FOR(x,0,w) {
        if(vs[y][x] == '1') ans[0]++;
        if(vs[y][x] == '2') ans[1]++;
      }
    }
    cout << ans[0] << " " << ans[1] << endl;
  }
  return 0;
}