// Arup Guha
// 3/24/2015
// Solution to 2014 March USACO Bronze Problem: Cow Art

import java.util.*;
import java.io.*;

public class cowart {

	// For floodfill.
	final public static int[] DX = {-1,0,0,1};
	final public static int[] DY = {0,-1,1,0};

	public static void main(String[] args) throws Exception {

		BufferedReader stdin = new BufferedReader(new FileReader("cowart.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		int n = Integer.parseInt(tok.nextToken());

		// Read in grid and sort.
		char[][] normal = new char[n][];
		for (int i=0; i<n; i++)
			normal[i] = stdin.readLine().toCharArray();
		stdin.close();

		// Our colorblind copy.
		char[][] blind = new char[n][n];
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (normal[i][j] == 'G')
					blind[i][j] = 'R';
				else
					blind[i][j] = normal[i][j];
			}
		}

		int regColors = solve(normal, n);
		int blindColors = solve(blind, n);

		// Write out the result.
		FileWriter fout = new FileWriter(new File("cowart.out"));
		fout.write(regColors+" "+blindColors+"\n");
		fout.close();
	}

	public static int solve(char[][] grid, int n) {

		int res = 0;
		boolean[][] used = new boolean[n][n];

		// Wrapper for floodfill.
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++) {
				if (!used[i][j]) {
					res++;
					floodfill(grid, used, i, j, n);
				}
			}
		}

		// Number of regions.
		return res;
	}

	public static void floodfill(char[][] grid, boolean[][] used, int x, int y, int n) {

		// Mark it.
		used[x][y] = true;

		// Floodfill
		for (int i=0; i<DX.length; i++)
			if (inbounds(x+DX[i], y+DY[i], n) && !used[x+DX[i]][y+DY[i]] && grid[x][y] == grid[x+DX[i]][y+DY[i]])
				floodfill(grid, used, x+DX[i], y+DY[i], n);
	}

	// Check in bounds.
	public static boolean inbounds(int x, int y, int n) {
		return x >= 0 && x < n && y >= 0 && y < n;
	}
}