# 적록색약 - BOJ
from collections import deque
from copy import deepcopy
dx = [1, -1, 0, 0]
dy = [0, 0, -1, 1]
def a_bfs(i, j):
cnt = 0
q1 = deque()
q1.append((i, j))
a_visit[i][j] = True
while q1:
x, y = q1.popleft()
for k in range(4):
nx = x + dx[k]
ny = y + dy[k]
if nx < 0 or ny < 0 or nx >= N or ny >= N or a_visit[nx][ny]:
continue
if a[nx][ny] == a[i][j]:
a_visit[nx][ny] = True
q1.append((nx, ny))
def b_bfs(i, j):
cnt = 0
q2 = deque()
q2.append((i, j))
b_visit[i][j] = True
while q2:
x, y = q2.popleft()
for k in range(4):
nx = x + dx[k]
ny = y + dy[k]
if nx < 0 or ny < 0 or nx >= N or ny >= N or b_visit[nx][ny]:
continue
if b[nx][ny] == b[i][j]:
b_visit[nx][ny] = True
q2.append((nx, ny))
N = int(input())
a = [list(input()) for _ in range(N)]
b = deepcopy(a)
for i in range(N):
for j in range(N):
if b[i][j] == 'G':
b[i][j] = 'R'
a_visit = [[False] * N for _ in range(N)]
b_visit = [[False] * N for _ in range(N)]
a_cnt = 0
b_cnt = 0
for i in range(N):
for j in range(N):
if not a_visit[i][j]:
a_bfs(i, j)
a_cnt += 1
if not b_visit[i][j]:
b_bfs(i, j)
b_cnt += 1
print(a_cnt, b_cnt)