def fill(MAP,xy,stick):
    global w,h
    if stick=='B': sflag=0
    else: sflag=1
    x,y=(xy[0],xy[1])
    if MAP[y][x][sflag]==0: MAP[y][x][sflag]=1
    xlist=[1,-1,0,0]
    ylist=[0,0,1,-1]
    for dx,dy in zip(xlist,ylist):
        nx=x+dx
        ny=y+dy
        if 0<=nx<w and 0<=ny<h:
            if  MAP[ny][nx][0]==-1 or MAP[ny][nx][1]==-1:
                continue
            elif MAP[ny][nx][sflag]==0:
                fill(MAP,[nx,ny],stick)

def countMAP(MAP):
    global w,h
    countB=0
    countW=0
    for x in range(w):
        for y in range(h):
            if MAP[y][x]==[1,0]:
                countB+=1
            elif MAP[y][x]==[0,1]:
                countW+=1
    return countB,countW

while  True:
    w,h=map(int,input().split())
    if w==h==0: break
    MAP=[]
    for i in range(h):
        temp=input()
        MAP.append([])
        for j in range(w):
            if temp[j]=='.': MAP[i].append([0,0])
            elif temp[j]=='B': MAP[i].append([-1,0])
            else: MAP[i].append([0,-1])
    for y in range(h):
        for x in range(w):
            if MAP[y][x][0]==-1:
                fill(MAP,[x,y],'B')
            elif MAP[y][x][1]==-1:
                fill(MAP,[x,y],'W')
    countB,countW=countMAP(MAP)
    print(countB,countW)
