#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000
int ans = 1;
map<int,int> mp;
bool check(int a,int b){
	if(mp[a]<=0)return false;
	ans = mod(ans * mp[a]);
	mp[a]--;
	mp[b]++;
	return true;
}

int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	
	mp[0] = N;
	
	
	
	for(int i=0;i<3*N;i++){
		if(S[i]=='R'){
			if(check(23,123))continue;
			if(check(2,12))continue;
			if(check(3,13))continue;
			if(check(0,1))continue;
					}
		else if(S[i]=='G'){
			if(check(13,123))continue;
			if(check(1,12))continue;
			if(check(3,23))continue;
			if(check(0,2))continue;
		}
		else{
			if(check(12,123))continue;
			if(check(1,13))continue;
			if(check(2,23))continue;
			if(check(0,3))continue;
		}
		
	}
	cout<<ans<<endl;
	
	return 0;
}
