#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 998244353;
const int MN = 100005;

int N;
char Str[3 * MN];
int sr[MN], cr;
int sg[MN], cg;
int sb[MN], cb;
int A[3 * MN];
int Ans;

int main() {
	scanf("%d", &N), Ans = 1;
	scanf("%s", Str + 1);
	for (int i = 1; i <= 3 * N; ++i) {
		if (Str[i] == 'R') sr[++cr] = i;
		if (Str[i] == 'G') sg[++cg] = i;
		if (Str[i] == 'B') sb[++cb] = i;
	}
	for (int i = 1; i <= N; ++i)
		A[std::min(sr[i], std::min(sg[i], sb[i]))] = 1,
		A[std::max(sr[i], std::max(sg[i], sb[i]))] = 2,
		Ans = (LL)Ans * i % Mod;
	for (int i = 1, S = 0; i <= 3 * N; ++i) {
		if (!A[i]) Ans = (LL)Ans * S % Mod, --S;
		if (A[i] == 1) ++S;
	}
	for (int i = 3 * N, S = 0; i >= 1; --i) {
		if (!A[i]) Ans = (LL)Ans * S % Mod, --S;
		if (A[i] == 2) ++S;
	}
	printf("%d\n", Ans);
	return 0;
}