import sys
import copy
input = sys.stdin.readline
def normal_dfs(graph, x, y, flag, N):
dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
pal = ['R', 'G']
stack = [[x, y]]
while stack:
index = stack.pop()
x1 = index[0]
y1 = index[1]
answer = graph[x1][y1]
graph[x1][y1] = -1
for i in range(4):
nx = x1 + dx[i]
ny = y1 + dy[i]
if(0 <= nx < N and 0 <= ny < N):
if(flag == 0):
if(graph[nx][ny] == answer and graph[nx][ny] != -1):
stack.append([nx,ny])
else:
if(graph[nx][ny] == answer and graph[nx][ny] != -1):
stack.append([nx,ny])
else:
if(answer in pal and graph[nx][ny] in pal and graph[nx][ny] != -1):
stack.append([nx,ny])
N = int(input())
table1 = []
for _ in range(N):
row = list(input().rstrip())
table1.append(row)
table2 = copy.deepcopy(table1)
cnt1, cnt2 = 0, 0
for i in range(N):
for j in range(N):
if(table1[i][j] != -1):
cnt1 += 1
normal_dfs(table1, i, j, 0, N)
if(table2[i][j] != -1):
cnt2 += 1
normal_dfs(table2, i, j, 1, N)
print(f'{cnt1} {cnt2}')