//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 998244353;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	string S; cin >> S;
	COMinit();
	int l = 0;
	int r = 0;
	bool R = 0, G = 0, B = 0;
	int cR = 0, cG = 0, cB = 0;
	ll ans = 1;
	map<char, int>mp;
	mp['R'] = 0; mp['G'] = 1, mp['B'] = 2;
	vector<int>hav(3), cnt(3);
	int st = 0;
	REP(i, 3 * N) {
		int pos = mp[S[i]];
		int A = (pos + 1) % 3;
		int B = (pos + 2) % 3;
		/*if (cnt[pos] > 0&&(hav[A]==0||hav[B]==0)) {
		cnt[pos]++;
		ans = mult(ans, cnt[pos]);
		cnt[A] = 0;
		cnt[B] = 0;
		}
		else {
		cnt[pos] = 1;
		}*/

		if ((cnt[A] == 0 && cnt[B] == 0&&st==0)||(hav[pos]>0&&cnt[A]==0&&cnt[B]==0)) {
			cnt[pos]++;
			hav[pos]++;
			//ans = mult(ans, cnt[pos]);
		}
		else if (hav[A] > 0 && hav[B] > 0) {
			ans *= st;
			ans %= MOD;
			st--;
			hav[A]--, hav[B]--;
			//cnt[pos] = 0; cnt[A] = 0; cnt[B] = 0;
		}
		else if (cnt[A] > 0) {
			st++;
			ans *= max((ll)1,cnt[A]);
			ans %= MOD;
			cnt[A]--;
			hav[pos]++;
			//cnt[A] = 0;
		}
		else if (cnt[B] > 0) {
			st++;
			ans = mult(ans, max((ll)1,cnt[B]));
			cnt[B]--;
			hav[pos]++;
		}
	}
	//while (l < 3 * N&&r<3*N) {
	//	//print(r);
	//	if (S[r] == 'R') {
	//		R = true;
	//		cR++;
	//	}
	//	else if (S[r] == 'G') {
	//		G = true;
	//		cG++;
	//	}
	//	else if (S[r] == 'B') {
	//		B = true;
	//		cB++;
	//	}
	//	if (cR>0&&cG>0&&cB>0) {
	//		if (r < 3 * N - 1 && S[r + 1] == S[r]) {
	//			r++;
	//			continue;
	//		}
	//		ans = mult(ans, fac[cG]);
	//		ans = mult(ans, fac[cB]);
	//		if (ans < 0)return 1;
	//		ans %= MOD;
	//		int mn = min({ cR,cG,cB });
	//		cR -= mn, cG -= mn, cB -= mn;
	//		l = r;
	//	}
	//	if (r == 3 * N-1)break;
	//	r++;
	//}
	ans *= fac[N];
	ans %= MOD;
	if (ans < 0)return 1;
	print(ans);
}



Measured memory_bytes: 5396