using System;
using System.Collections.Generic;
using System.Linq;

namespace V2014{
    public class Program{
        int W;
        int H;
        string[] A;

        int[][] _grid;
        int[] _dx = {1, 0, -1, 0};
        int[] _dy = {0, 1, 0, -1};

        bool IsInside(int x, int y){
            return 0 <= x && x < W && 0 <= y && y < H;
        }

        public static void Main(string[] args){
            new Program().Solve();
        }

        void Solve(){
            var sr = new StreamReader();
            while(true){
                W = sr.Next<int>();
                H = sr.Next<int>();
                A = sr.Next<string>(H);
                if(W + H == 0) return;

                _grid = new int[H, W].ToJaggedArray();
                for(var i = 0; i < H; i++){
                    for(var j = 0; j < W; j++){
                        _grid[i][j] = ".BW".IndexOf(A[i][j]);
                    }
                }

                var dic = new Dictionary<int, int>{{-1, 0}, {1, 0}};
                for(var i = 0; i < H; i++){
                    for(var j = 0; j < W; j++){
                        var count = Bfs(j, i);
                        if(dic.ContainsKey(Math.Sign(count))){
                            dic[Math.Sign(count)] += Math.Sign(count) * count;
                        }
                    }
                }
                Console.WriteLine(string.Join(" ", dic.Values.Select(x => x.ToString()).ToArray()));
            }
        }

        int Bfs(int x, int y){
            if(_grid[y][x] != 0) return 0;

            var count = 1;
            _grid[y][x] = int.MinValue;
            var hs = new HashSet<int>();

            var que = new Queue<int>();
            que.Enqueue(x);
            que.Enqueue(y);

            while(que.Count > 0){
                var cx = que.Dequeue();
                var cy = que.Dequeue();
                for(var i = 0; i < _dx.Length; i++){
                    var nx = cx + _dx[i];
                    var ny = cy + _dy[i];
                    if(IsInside(nx, ny) && _grid[ny][nx] != int.MinValue){
                        if(_grid[ny][nx] == 0){
                            que.Enqueue(nx);
                            que.Enqueue(ny);
                            _grid[ny][nx] = int.MinValue;
                            count++;
                        } else{
                            hs.Add(_grid[ny][nx]);
                        }
                    }
                }
            }
            if(hs.Count != 1) return 0;
            return (2 * hs.Single() - 3) * count;
        }
    }

    public static class ExMethod{
        public static T[][] ToJaggedArray<T>(this T[,] src){
            var x = src.GetLength(1);
            var y = src.GetLength(0);
            var ret = new T[y][];

            for(var i = 0; i < y; i++){
                ret[i] = new T[x];
                for(var j = 0; j < x; j++){
                    ret[i][j] = src[i, j];
                }
            }

            return ret;
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 11924