#include <iostream>
#include <queue>
#include <utility>
#include <cctype>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

typedef pair<int,int> pii;

int main()
{
  while(1){
    int w, h;
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    char map[h][w];
    REP(i,h){
      REP(j,w){
        cin >> map[i][j];
      }
    }
    queue<pii> a;
    REP(i,h){
      REP(j,w){
        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(pii(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(pii(i-1,j));
            }
          }
          if(i < h - 1){
            if(map[i+1][j] == '.'){
              map[i+1][j] = tolower(map[i][j]);
              a.push(pii(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(pii(i+1,j));
            }
          }
          if(j > 0){
            if(map[i][j-1] == '.'){
              map[i][j-1] = tolower(map[i][j]);
              a.push(pii(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(pii(i,j-1));
            }
          }
          if(j < w - 1){
            if(map[i][j+1] == '.'){
              map[i][j+1] = tolower(map[i][j]);
              a.push(pii(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(pii(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(pii(x,y));
            a.push(pii(x-1,y));
          }else if(map[x-1][y] == '.'){
            map[x-1][y] = 'b';
            a.push(pii(x-1,y));
          }else if(map[x-1][y] == 'W'){
            map[x][y] = x;
            a.push(pii(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(pii(x,y));
            a.push(pii(x-1,y));
          }else if(map[x-1][y] == '.'){
            map[x-1][y] = 'w';
            a.push(pii(x-1,y));
          }else if(map[x-1][y] == 'B'){
            map[x][y] = x;
            a.push(pii(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(pii(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(pii(x,y));
            a.push(pii(x+1,y));
          }else if(map[x+1][y] == '.'){
            map[x+1][y] = 'b';
            a.push(pii(x+1,y));
          }else if(map[x-1][y] == 'W'){
            map[x][y] = x;
            a.push(pii(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(pii(x,y));
            a.push(pii(x+1,y));
          }else if(map[x+1][y] == '.'){
            map[x+1][y] = 'w';
            a.push(pii(x+1,y));
          }else if(map[x-1][y] == 'B'){
            map[x][y] = x;
            a.push(pii(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(pii(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(pii(x,y));
            a.push(pii(x,y-1));
          }else if(map[x][y-1] == '.'){
            map[x][y-1] = 'b';
            a.push(pii(x,y-1));
          }else if(map[x-1][y] == 'W'){
            map[x][y] = x;
            a.push(pii(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(pii(x,y));
            a.push(pii(x,y-1));
          }else if(map[x][y-1] == '.'){
            map[x][y-1] = 'w';
            a.push(pii(x,y-1));
          }else if(map[x-1][y] == 'B'){
            map[x][y] = x;
            a.push(pii(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(pii(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(pii(x,y));
            a.push(pii(x,y+1));
          }else if(map[x][y+1] == '.'){
            map[x][y+1] = 'b';
            a.push(pii(x,y+1));
          }else if(map[x-1][y] == 'W'){
            map[x][y] = x;
            a.push(pii(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(pii(x,y));
            a.push(pii(x,y+1));
          }else if(map[x][y+1] == '.'){
            map[x][y+1] = 'w';
            a.push(pii(x,y+1));
          }else if(map[x-1][y] == 'B'){
            map[x][y] = x;
            a.push(pii(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(pii(x,y+1));
          }
        }
      }
    }
    pii ans;
    ans.first = ans.second = 0;
    REP(i,h){
      REP(j,w){
          if(map[i][j] == 'b')
          ans.first++;
        else if(map[i][j] == 'w')
          ans.second++;
      }
    }
    cout << ans.first << " " << ans.second << endl;
  }
}

Measured memory_bytes: 1232