$dx = [0,1,0,-1]
$dy = [1,0,-1,0]
$bc = 0
$wc = 0
def bfs(f, sy, sx, h, w, visited, bc, wc)
    f[sy][sx] = "*"
    wf = false
    bf = false
    count = 1
    q = [[sy,sx]]
    visited.push([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) && !visited.include?([cy,cx])
                if  f[cy][cx] == "W"
                    wf = true
                elsif
                    f[cy][cx] == "B"
                    bf = true
                elsif
                    count += 1
                    q.push([cy,cx])
                    visited.push([cy,cx])
                    f[cy][cx] = "*"
                end
            end
        end
    end
    bc += count if bf && !wf
    wc += count if !bf && wf
    return [f,visited,bc,wc]
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}
    visited = []
    bc = wc = 0
    h.times do |i|
        w.times do |j|
            next if f[i][j] == "W" || f[i][j] == "B" || visited.include?([i,j])
            f, visited, bc, wc = bfs(f,i,j,h,w,visited,bc,wc)
        end
    end
    puts "#{bc} #{wc}"
end