#include<bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 10;
const int MOD = 998244353;
 
inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }
 
inline int power(int x, int k) {
  int tmp = 1;
  while(k) {
    if(k & 1) tmp = mul(tmp,x);
    x = mul(x,x);
    k >>= 1;
  }
  return tmp;
}

int n, cnt[4], a[4], b[4];
char s[maxn];

inline int get(char c) {
	if(c == 'R') return 0;
	if(c == 'G') return 1;
	if(c == 'B') return 2;
}

int main() {
//	freopen("data.in","r",stdin);
  scanf("%d%s", &n, s + 1);
	int Ans = 1;
	for(int i = 1;i <= n;i ++) Ans = mul(Ans,i);
	for(int i = 1;i <= 3 * n;i ++) {
		for(int j = 0;j < 3;j ++) a[j] = cnt[j];
		cnt[get(s[i])] ++;
		for(int j = 0;j < 3;j ++) b[j] = cnt[j];
		sort(a,a + 3); sort(b,b + 3);
		if(a[0] != b[0]) Ans = mul(Ans,a[1] - a[0]);
		if(a[1] != b[1]) Ans = mul(Ans,a[2] - a[1]);
	}
	printf("%d\n", Ans);
	return 0;
}
