from sys import setrecursionlimit
setrecursionlimit(10000)
n = int(input())
grid = []
visited = [[False for i in range(n)] for i in range(n)]
cnt = 0
for _ in range(n):
grid.append(list(input()))
color = ""
colors = []
colors2 = []
def is_valid(x,y):
if x >= 0 and x < n and y >= 0 and y < n:
return True
return False
def dfs(g,x,y):
global color
if not is_valid(x,y):
return False
if visited[x][y] == False and g[x][y] == color:
visited[x][y] = True
global cnt
cnt += 1
dfs(g,x-1,y)
dfs(g,x+1,y)
dfs(g,x,y+1)
dfs(g,x,y-1)
return True
return False
for x in range(n):
for y in range(n):
if grid[x][y] != 0:
color = grid[x][y]
if dfs(grid,x,y):
colors.append(color)
visited = [[False for i in range(n)] for i in range(n)]
for x in range(n):
for y in range(n):
if grid[x][y] == "R":
grid[x][y] = "G"
for x in range(n):
for y in range(n):
if grid[x][y] != 0:
color = grid[x][y]
if dfs(grid,x,y):
colors2.append(color)
print(len(colors) , len(colors2))