from collections import deque

while True:

    W,H = map(int,input().split())

    if W == 0 and H == 0:
        break

    a = []

    for i in range(H):

        A = list(input())
        a.append(A)

    q = deque([])

    for i in range(H):
        for j in range(W):

            if a[i][j] in ["W","B"]:
                q.append([i,j])

    while len(q) > 0:

        now = q.pop()
        nx = now[0]
        ny = now[1]

        if a[nx][ny] in[ "W","X" ]:

            if nx - 1 >= 0 and a[nx-1][ny] == ".":
                a[nx-1][ny] = "X"
                q.append([nx-1,ny])

            if ny - 1 >= 0 and a[nx][ny-1] == ".":
                a[nx][ny-1] = "X"
                q.append([nx,ny-1])

            if nx + 1 < H and a[nx+1][ny] == ".":
                a[nx+1][ny] = "X"
                q.append([nx+1,ny])

            if ny + 1 < W and a[nx][ny+1] == ".":
                a[nx][ny+1] = "X"
                q.append([nx,ny+1])


        if a[nx][ny] in ["B","C"]:

            if nx - 1 >= 0 and a[nx-1][ny] == ".":
                a[nx-1][ny] = "C"
                q.append([nx-1,ny])

            if ny - 1 >= 0 and a[nx][ny-1] == ".":
                a[nx][ny-1] = "C"
                q.append([nx,ny-1])

            if nx + 1 < H and a[nx+1][ny] == ".":
                a[nx+1][ny] = "C"
                q.append([nx+1,ny])

            if ny + 1 < W and a[nx][ny+1] == ".":
                a[nx][ny+1] = "C"
                q.append([nx,ny+1])

        if a[nx][ny] in ["B","C","Z"]:

            if nx - 1 >= 0 and a[nx-1][ny] == "X":
                a[nx-1][ny] = "Z"
                q.append([nx-1,ny])

            if ny - 1 >= 0 and a[nx][ny-1] == "X":
                a[nx][ny-1] = "Z"
                q.append([nx,ny-1])

            if nx + 1 < H and a[nx+1][ny] == "X":
                a[nx+1][ny] = "Z"
                q.append([nx+1,ny])

            if ny + 1 < W and a[nx][ny+1] == "X":
                a[nx][ny+1] = "Z"
                q.append([nx,ny+1])


        if a[nx][ny] in ["W","X","Z"]:

            if nx - 1 >= 0 and a[nx-1][ny] == "C":
                a[nx-1][ny] = "Z"
                q.append([nx-1,ny])

            if ny - 1 >= 0 and a[nx][ny-1] == "C":
                a[nx][ny-1] = "Z"
                q.append([nx,ny-1])

            if nx + 1 < H and a[nx+1][ny] == "C":
                a[nx+1][ny] = "Z"
                q.append([nx+1,ny])

            if ny + 1 < W and a[nx][ny+1] == "C":
                a[nx][ny+1] = "Z"
                q.append([nx,ny+1])

    bn = 0
    wn = 0
    for i in range(H):

        #print (a[i])

        for j in range(W):

            if a[i][j] == "C":
                bn += 1
            elif a[i][j] == "X":
                wn += 1
    
    print (bn,wn)

