import java.io.*;
import java.util.*;
public class Main {
static int[] dr = { -1, 0, 1, 0 };
static int[] dc = { 0, 1, 0, -1 };
static boolean[][] v, cv;
static int N, count, ccount;
static char[][] grid, cgrid;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
grid = new char[N][N];
cgrid = new char[N][N];
for (int i = 0; i < N; i++) {
String str = br.readLine();
for (int j = 0; j < N; j++) {
char col = str.charAt(j);
grid[i][j] = col;
if (col == 'G') cgrid[i][j] = 'R';
else cgrid[i][j] = col;
}
}
v = new boolean[N][N]; count = 0;
cv = new boolean[N][N]; ccount = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (!v[i][j]) {
dfs(i, j, v, grid, grid[i][j]);
count++;
}
if (!cv[i][j]) {
dfs(i, j, cv, cgrid, cgrid[i][j]);
ccount++;
}
}
}
System.out.println(count + " " + ccount);
}
static void dfs(int r, int c, boolean[][] bool, char[][] area, char color) {
bool[r][c] = true;
for (int i = 0; i < 4; i++) {
int nr = r + dr[i];
int nc = c + dc[i];
if (0 <= nr && nr < N && 0 <= nc && nc < N && !bool[nr][nc] && area[nr][nc] == color) {
dfs(nr, nc, bool, area, color);
}
}
}
}