#include <cstdio>
#define Mod 998244353
#define Maxn 300000
int b[5];
char s[Maxn+5];
int f(char c){
	if(c=='R'){
		return 0;
	}
	if(c=='G'){
		return 1;
	}
	return 2;
}
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	int ans=1;
	int t0,t1,t2;
	for(int i=1;i<=3*n;i++){
		t0=f(s[i]);
		t1=(t0+1)%3;
		t2=(t1+1)%3;
		if(b[t0]>=b[t1]&&b[t0]>=b[t2]){
			b[t0]++;
			continue;
		}
		else if(b[t0]<b[t1]&&b[t0]>=b[t2]){
			ans=1ll*ans*(b[t1]-b[t0])%Mod;
		}
		else if(b[t0]<b[t2]&&b[t0]>=b[t1]){
			ans=1ll*ans*(b[t2]-b[t0])%Mod;
		}
		else if(b[t1]<b[t2]){
			ans=1ll*ans*(b[t1]-b[t0])%Mod;
		}
		else{
			ans=1ll*ans*(b[t2]-b[t0])%Mod;
		}
		b[t0]++;
	}
	for(int i=1;i<=n;i++){
		ans=1ll*i*ans%Mod;
	}
	printf("%d\n",ans);
	return 0;
}
