import Foundation
let n = Int(readLine()!)!
var graph = [[String]]()
var visited = [[Bool]]()
var cnt = [0, 0]
let dx = [-1, 1, 0, 0]
let dy = [0, 0, -1, 1]
for _ in 0..<n {
graph.append(readLine()!.map{ String($0) })
visited.append(Array<Bool>(repeating: false, count: n))
}
func bfs(_ x: Int, _ y: Int, isRG: Bool) {
var queue = [[x, y]]
let color = graph[x][y]
visited[x][y] = true
while !queue.isEmpty {
let now = queue.removeFirst()
for i in 0..<4 {
let nx = now[0] + dx[i]
let ny = now[1] + dy[i]
if 0..<n ~= nx && 0..<n ~= ny && !visited[nx][ny] {
if isRG && (color == "R" || color == "G") && (graph[nx][ny] == "R" || graph[nx][ny] == "G") {
queue.append([nx, ny])
visited[nx][ny] = true
}
else if graph[nx][ny] == color {
queue.append([nx, ny])
visited[nx][ny] = true
}
}
}
}
}
for i in 0..<n {
for j in 0..<n {
if !visited[i][j] {
bfs(i, j, isRG: false)
cnt[0] += 1
}
}
}
visited = Array.init(repeating: Array<Bool>(repeating: false, count: n), count: n)
for i in 0..<n {
for j in 0..<n {
if !visited[i][j] {
bfs(i, j, isRG: true)
cnt[1] += 1
}
}
}
print("\(cnt[0]) \(cnt[1])")