$field
$visited
$cnt
$b_flg
$w_flg
$w
$h
$dy = Array[0, -1, 0, 1]
$dx = Array[1, 0, -1, 0]

def search(i, j)
  $cnt += 1
  $visited[i][j] = true

  for k in 0...4
    y = i + $dy[k]
    x = j + $dx[k]
    if y < 0 || $h <= y
      next
    end
    if x < 0 || $w <= x
      next
    end
    if $visited[y][x]
      next
    end
    if $field[y][x] == 'B'
      $b_flg = true
    elsif $field[y][x] == 'W'
      $w_flg = true
    else
      search(y, x)
    end
  end
end

loop do
  $w, $h = gets.chomp.split.map(&:to_i)

  if $w == 0 && $h == 0
    break;
  end

  $field = Array.new($h)
  $visited = Array.new($h)

  for i in 0...$h
    $field[i] = gets.chomp.split(//).map(&:to_s)
    $visited[i] = Array.new($w, false)
  end

  ans_b = ans_w = 0

  for i in 0...$h
    for j in 0...$w
      if $field[i][j] == '.' && !$visited[i][j]
        $b_flg = $w_flg = false
        $cnt = 0
        search(i, j)
        if $b_flg && !$w_flg
          ans_b += $cnt
        elsif !$b_flg && $w_flg
          ans_w += $cnt
        end
      end
    end
  end

  puts "#{ans_b} #{ans_w}"
end