while true
    @w,@h=gets.split(" ").map(&:to_i)
    if @w==0
        break
    end
    a=(0...@h).map{gets}
    @flag=Array.new(@h).map{Array.new(@w,0)}
    @h.times do |i|
        @w.times do |j|
            if a[i][j]=='W'
                @flag[i][j]|=1
            elsif a[i][j]=='B'
                @flag[i][j]|=2
            end
        end
    end
    def solve(x,y,c)
        dx=[0,1,0,-1]
        dy=[1,0,-1,0]
        4.times do |i|
            if x+dx[i]<0||x+dx[i]>=@w||y+dy[i]<0||y+dy[i]>=@h
                next
            end
            if @flag[y+dy[i]][x+dx[i]]&3>0
                next
            end
            if @flag[y+dy[i]][x+dx[i]]&c>0
                next
            end
            @flag[y+dy[i]][x+dx[i]]|=c
            solve(x+dx[i],y+dy[i],c)
        end
    end
    @h.times do |i|
        @w.times do |j|
            if @flag[i][j]==1
                solve(j,i,4)
            elsif @flag[i][j]==2
                solve(j,i,8)
            end
        end
    end
    bcnt=0
    wcnt=0
    @h.times do |i|
        @w.times do |j|
            if @flag[i][j]&15==4
                wcnt+=1
            elsif @flag[i][j]&15==8
                bcnt+=1
            end
        end
    end
    print("#{bcnt} #{wcnt}\n")
end