#include<iostream>
#define int long long 
const int mod=998244353;
#define br rb
#define bg gb
#define gr rg
using namespace std;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,r=0,g=0,b=0,rg=0,rb=0,bg=0,ans=1;
	string s;
	cin>>n>>s;
	s=" "+s;
	for(i=1;i<=3*n;i++){
		if(s[i]=='R'){
			if(bg){
				ans*=bg;
				ans%=mod;
				bg--;
				continue;
			}
			if(b){
				ans*=b;
				ans%=mod;
				b--;
				rb++;
				continue;
			}
			if(g){
				ans*=g;
				ans%=mod;
				g--;
				rg++;
				continue;
			}
			r++;
		}
		if(s[i]=='B'){
			if(rg){
				ans*=rg;
				ans%=mod;
				rg--;
				continue;
			}
			if(r){
				ans*=r;
				ans%=mod;
				r--;
				rb++;
				continue;
			}
			if(g){
				ans*=g;
				ans%=mod;
				g--;
				gb++;
				continue;
			}
			b++;
		}
		if(s[i]=='G'){
			if(br){
				ans*=br;
				ans%=mod;
				br--;
				continue;
			}
			if(b){
				ans*=b;
				ans%=mod;
				b--;
				bg++;
				continue;
			}
			if(r){
				ans*=r;
				ans%=mod;
				r--;
				gr++;
				continue;
			}
			g++;
		}
	}
	for(i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	cout<<ans;
}