# 입력
import sys
from collections import deque
sys.setrecursionlimit(10**6)
n = int(sys.stdin.readline().strip())
maps = [[] * n for _ in range(n)]
for i in range(n):
maps[i] = list(sys.stdin.readline().strip())
count = 0
visited = [[False] * n for _ in range(n)]
dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
# 처리
def bfs(i, j, color):
queue = deque()
queue.append([i, j])
visited[i][j] = True
while queue:
i, j = queue.popleft()
for k in range(4):
x = i + dx[k]
y = j + dy[k]
if not 0 <= x < n or not 0 <= y < n or visited[x][y]:
continue
if color == maps[x][y]:
visited[x][y] = True
queue.append([x, y])
return
for i in range(n):
for j in range(n):
if visited[i][j] == False:
bfs(i, j, maps[i][j])
count += 1
print(count, end=" ")
def bfs_blind(i, j, color):
queue = deque()
queue.append([i, j])
visited[i][j] = True
while queue:
i, j = queue.popleft()
for k in range(4):
x = i + dx[k]
y = j + dy[k]
if not 0 <= x < n or not 0 <= y < n or visited[x][y]:
continue
if color == "B" and maps[x][y] == "B":
visited[x][y] = True
queue.append([x, y])
elif color != "B" and maps[x][y] != "B":
visited[x][y] = True
queue.append([x, y])
return
count = 0
visited = [[False] * n for _ in range(n)]
for i in range(n):
for j in range(n):
if visited[i][j] == False:
bfs_blind(i, j, maps[i][j])
count += 1
print(count)