#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int b[3];
int f(char c)
{
	if(c == 'R') return 0;
	if(c == 'G') return 1;
	return 2;
} 
int main()
{
	int n;
	scanf("%d\n",&n);
	int ans = 1;
	for(int i = 3*n;i >= 1;i --)
	{
		char c;scanf("%c",&c);
		int t0 = f(c);int t1 = (f(c)+1)%3;int t2 = (t1+1)%3;
		if(b[t0] >= b[t1] && b[t0] >= b[t2]) {}
		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;
}