#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int mod=998244353;
char s[300050];
int A[100050],B[100050],C[100050];
vector<int> a,b,c;
int main(){
	int n,i,x,ans=1;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n*3;++i)if(s[i]=='R')a.push_back(i);
	else if(s[i]=='G')b.push_back(i);
	else c.push_back(i);
	for(i=0;i<n;++i)if(a[i]<b[i])if(a[i]<c[i]){
		A[i+1]=a[i];
		if(b[i]<c[i]){B[i+1]=b[i];C[i+1]=c[i];}
		else{B[i+1]=c[i];C[i+1]=b[i];}
	}else{A[i+1]=c[i];B[i+1]=a[i];C[i+1]=b[i];}
	else if(b[i]<c[i]){
		A[i+1]=b[i];
		if(a[i]<c[i]){B[i+1]=a[i];C[i+1]=c[i];}
		else{B[i+1]=c[i];C[i+1]=a[i];}
	}else{A[i+1]=c[i];B[i+1]=b[i];C[i+1]=a[i];}
	for(i=1;i<=n;++i){
		x=upper_bound(A+1,A+n+1,B[i])-A-1;
		ans=(ll)ans*(x-i+1)%mod*i%mod;
	}
	for(i=n;i;--i){
		x=lower_bound(C+1,C+n+1,B[i])-C;
		ans=(ll)ans*(i-x+1)%mod;
	}
	printf("%d\n",ans);
	return 0;
}