class UnionFind
	def initialize
		@obj_to_node = {}
	end

	def add(obj)
		@obj_to_node[obj] ||= Node.new(obj)
	end

	def size(x = nil)
		x ? @obj_to_node[x].root.size : @obj_to_node.size
	end

	class Node
		def initialize(obj)
			@obj = obj
			@parent = self
			@size = 1
		end

		def root
			return self if @parent == self
			@parent = @parent.root
		end	

		attr_accessor :parent, :size
	end

	def union(x, y)
		u = (@obj_to_node[x] ||= Node.new(x)).root
		v = (@obj_to_node[y] ||= Node.new(y)).root
		return if u == v
		u.parent = v.root
		v.size += u.size
	end

	def same?(x, y)
		return false unless u = @obj_to_node[x]
		return false unless v = @obj_to_node[y]
		u.root == v.root
	end

	def root_of(x)
		u = @obj_to_node[x]
		u ? u.root : nil
	end
end

require 'set'
loop {
	w, h = gets.split.map &:to_i
	break if w == 0
	a = (1..h).map{ gets.chomp.split("") }
	color = (1..h).map{ (1..w).map{ Set.new } }
	uf = UnionFind.new
	(0..h-1).each{|i|
		(0..w-1).each{|j|
			uf.add([i,j])
			if i < h-1
				color[i][j] << :w if a[i][j] == ?. && a[i+1][j] == ?W
				color[i][j] << :b if a[i][j] == ?. && a[i+1][j] == ?B
				color[i+1][j] << :w if a[i+1][j] == ?. && a[i][j] == ?W
				color[i+1][j] << :b if a[i+1][j] == ?. && a[i][j] == ?B
				uf.union([i,j], [i+1, j]) if a[i][j] == ?. && a[i+1][j] == ?.
			end
			if j < w-1
				color[i][j] << :w if a[i][j] == ?. && a[i][j+1] == ?W
				color[i][j] << :b if a[i][j] == ?. && a[i][j+1] == ?B
				color[i][j+1] << :w if a[i][j+1] == ?. && a[i][j] == ?W
				color[i][j+1] << :b if a[i][j+1] == ?. && a[i][j] == ?B
				uf.union([i,j], [i, j+1]) if a[i][j] == ?. && a[i][j+1] == ?.
			end
		}
	}

	hash = {}
	(0..h-1).each{|i|
		(0..w-1).each{|j|
			r = uf.root_of([i,j])
			hash[r] ||= Set.new
			hash[r] += color[i][j]
		}
	}
	white = black = 0
	hash.each{|r, cs|
		next unless r
		white += r.size if cs.to_a == [:w]
		black += r.size if cs.to_a == [:b]
	}
	puts "#{black} #{white}"
}