$dx = [0,1,0,-1]
$dy = [1,0,-1,0]
def bfs(f, sy, sx, h, w)
    q = [[sy,sx]]
    visited = [[sy,sx]]
    col = f[sy][sx].downcase
    while q.size > 0
        sy, sx = q.shift
        for i in 0..3
            cy = sy + $dy[i]
            cx = sx + $dx[i]
            if cy.between?(0,h-1) && cx.between?(0,w-1) && f[cy][cx] != "W" && f[cy][cx] != "B" && !visited.include?([cy,cx])
                q.push([cy,cx])
                visited.push([cy,cx])
                if f[cy][cx] == "."
                    f[cy][cx] = col
                elsif f[cy][cx] != col
                    f[cy][cx] = "*" 
                end
            end
        end
    end
    return f
end
def pp(f)
    f.each do |r|
        puts r
    end
    puts
end
loop do
    w, h = gets.split.map(&:to_i)
    break if w == 0 && h == 0
    f = h.times.map{gets.strip}
    h.times do |i|
        w.times do |j|
            next if f[i][j] != "W" && f[i][j] != "B"
            f = bfs(f,i,j,h,w)
        end
    end
    wc = bc = 0
    h.times do |i|
        w.times do |j|
            wc += 1 if f[i][j] == "w"
            bc += 1 if f[i][j] == "b"
        end
    end
    puts "#{bc} #{wc}"
end