링크 : https://www.acmicpc.net/problem/10026
/*
문제 : 적록색약
링크 : https://www.acmicpc.net/problem/10026
*/
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int N;
string arr[101];
bool visited[101][101];
//오 왼 상 하
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void dfs(int y, int x){
for(int i = 0; i < 4; i ++){
int nx = x + dx[i];
int ny = y + dy[i];
if(nx < 0 || ny < 0 || nx >= N || ny >= N) continue;
if(!visited[ny][nx] && arr[ny][nx] == arr[y][x]){
visited[ny][nx] = true;
dfs(ny, nx);
}
}
}
int main(){
cin >> N;
for(int i = 0; i < N; i++){
cin >> arr[i];
}
int cnt = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j< N; j++){
if(!visited[i][j]){
cnt++;
visited[i][j] = true;
dfs(i, j);
}
}
}
cout << cnt << " ";
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(arr[i][j] == 'G') arr[i][j] = 'R';
}
}
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
visited[i][j] = false;
}
}
cnt = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
if(!visited[i][j]){
cnt++;
visited[i][j] = true;
dfs(i, j);
}
}
}
cout << cnt;
return 0;
}