
W = 0
H = 0
island = list()

NOT_SUR = 0
BLACK = 1
WHITE = 2

def read_island():
    island = list()
    w, h = map(int, raw_input().split())
    for i in xrange(h):
        line = raw_input()
        chars = list()
        for ch in line:
            chars.append(ch)
        island.append(chars)

    return w, h, island


dir_x = [0, 1, 0, -1] # up, right, down, left
dir_y = [-1, 0, 1, 0]

def check_ex_adj(x, y, color):
    global island

    if island[y][x] != ".":
        return False

    for i in xrange(4):
        next_x = x + dir_x[i]
        next_y = y + dir_y[i]
        if not (0 <= next_x < W) or not (0 <= next_y < H):
            continue

        if island[y + dir_y[i]][x + dir_x[i]] == color:
            return True

    for i in xrange(4):
        next_x = x + dir_x[i]
        next_y = y + dir_y[i]
        if not (0 <= next_x < W) or not (0 <= next_y < H):
            continue

        island[y][x] = "B" if color == "W" else "W"
        is_ex_adj = check_ex_adj(next_x, next_y, color)
        island[y][x] = "."
        if is_ex_adj:
            return is_ex_adj

    return False


def check_surrounded(x, y):
    is_adj_b = check_ex_adj(x, y, "B")
    is_adj_w = check_ex_adj(x, y, "W")

    if is_adj_b and not is_adj_w:
        return BLACK
    elif not is_adj_b and is_adj_w:
        return WHITE

    return NOT_SUR


def solve():
    global W
    global H
    global island
    while True:
        W, H, island = read_island()
        if W == 0 and H == 0:
            break

        black_area = 0
        white_area = 0
        for x in xrange(W):
            for y in xrange(H):
                surrounded_by = check_surrounded(x, y)
                if surrounded_by == NOT_SUR:
                    continue

                if surrounded_by == BLACK: # Black
                    black_area += 1
                elif surrounded_by == WHITE:
                    white_area += 1

        print "{} {}".format(black_area, white_area)


if __name__ == "__main__":
    solve()