import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static int N;
static char[][] map;
static void DFS(char color, int r, int c, boolean[][] visited) {
if (r < 0 || r >= N)
return;
if (c < 0 || c >= N)
return;
if (map[r][c] != color)
return;
if (visited[r][c])
return;
System.out.println(r+":"+c);
visited[r][c] = true;
DFS(color, r - 1, c, visited);
DFS(color, r + 1, c, visited);
DFS(color, r, c - 1, visited);
DFS(color, r, c + 1, visited);
}
static int areaCount() {
boolean[][] visited = new boolean[N][N];
int count = 0;
for (int r = 0; r < N; ++r)
for (int c = 0; c < N; ++c)
if (visited[r][c] == false) {
++count;
char color = map[r][c];
DFS(color, r, c, visited);
}
return count;
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(reader.readLine());
map = new char[N][];
for (int i = 0; i < N; ++i)
map[i] = reader.readLine().toCharArray();
int count1 = areaCount();
for (int r = 0; r < N; ++r)
for (int c = 0; c < N; ++c)
if (map[r][c] == 'R')
map[r][c] = 'G';
int count2 = areaCount();
System.out.println(count1 + " " + count2);
}
}