#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;
string s;
/*
void hoge(){
	vector<Int> a, b, c;
	a = b = c = {0, 1, 2, 3, 4};
	Int mincost = 1e9;
	do{
		do{
			do{
				vector<Int> v(3*n, -1);
				Int rc, gc, bc;
				rc = gc = bc = 0;
				for(Int i=0; i<3*n; ++i){
					if(s[i] == 'R'){
						v[i] = a[rc];
						++rc;
					}else if(s[i] == 'G'){
						v[i] = b[gc];
						++gc;
					}else{
						v[i] = c[bc];
						++bc;
					}
				}
				Int cost = 0;
				for(Int i=0; i<n; ++i){
					Int l = 0, r = 0;
					for(Int j=0; j<3*n; ++j)
						if(v[j] == i){
							l = j;
							break;
						}
					for(Int j=3*n-1; j>=0; --j)
						if(v[j] == i){
							r = j;
							break;
						}
					cost += r - l;
				}
				mincost = min(mincost, cost);
			}while(next_permutation(c.begin(), c.end()));
		}while(next_permutation(b.begin(), b.end()));
	}while(next_permutation(a.begin(), a.end()));
	cout << mincost << "\n";
}
*/
template<Int Mod = 998244353> class modint{
public:
	Int val;
	constexpr modint(const Int x = 0) : val(x % Mod) {if(val < 0) val += Mod;}
	constexpr modint operator+(const modint rhs) const {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const {
		return modint(*this) /= rhs;
	}
	constexpr modint operator-() const {
		return modint(Mod - val);
	}
	constexpr modint &operator+=(const modint rhs){
		val += rhs.val;
		if(val >= Mod) val -= Mod;
		return *this;
	}
	constexpr modint &operator-=(const modint rhs){
		if(val < rhs.val) val += Mod;
		val -= rhs.val;
		return *this;
	}
	constexpr modint &operator*=(const modint rhs){
		val *= rhs.val;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator/=(const modint rhs){
		return *this *= inv(rhs);
	}
	constexpr modint &operator++(){
		++val;
		if(val == Mod) val = 0;
		return *this;
	}
	constexpr modint &operator--(){
		--val;
		if(val == -1) val = Mod - 1;
		return *this;
	}
	constexpr modint operator<<(const Int rhs) const {
		return modint(*this) << rhs;
	}
	constexpr modint operator>>(const Int rhs) const {
		return modint(*this) >> rhs;
	}
	constexpr modint &operator<<=(const Int rhs){
		val <<= rhs;
		val %= Mod;
		return *this;
	}
	constexpr modint &operator>>=(const Int rhs){
		val >>= rhs;
		val %= Mod;
		return *this;
	}
	constexpr bool operator==(const modint rhs) const {
		return val == rhs.val;
	}
	constexpr bool operator!=(const modint rhs) const {
		return val != rhs.val;
	}
	constexpr bool operator<(const modint rhs) const {
		return val < rhs.val;
	}
	constexpr bool operator>(const modint rhs) const {
		return val > rhs.val;
	}
	constexpr bool operator<=(const modint rhs) const {
		return val <= rhs.val;
	}
	constexpr bool operator>=(const modint rhs) const {
		return val >= rhs.val;
	}
	friend ostream& operator<<(ostream& os, const modint<Mod>& m){
		return os << m.val;
	}
	friend istream& operator>>(istream& is, modint<Mod>& m){
		return is >> m.val;
	}
	static constexpr modint inv(modint m){
		Int a = m.val, b = Mod, u = 1, v = 0;
		while(b){
			Int t = a / b;
			a -= t * b;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		u %= Mod;
		if(u < 0) u += Mod;
		return modint(u);
	}
	constexpr operator Int() const {
		return val;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> s;
//	hoge();
	vector<Int> v(s.size(), -1);
	priority_queue<Int, vector<Int>, greater<>> pq[3];
	for(size_t i=0; i<s.size(); ++i){
		if(s[i] == 'R') pq[0].push((Int)i);
		else if(s[i] == 'G') pq[1].push((Int)i);
		else pq[2].push((Int)i);
	}
	for(Int i=0; i<n; ++i){
		vector<Int> w;
		for(Int j=0; j<3; ++j){
			w.push_back(pq[j].top());
			pq[j].pop();
		}
		sort(w.begin(), w.end());
		for(Int j=0; j<3; ++j)
			v[w[j]] = j;
	}
//	for(size_t i=0; i<s.size(); ++i)
//		cout << i << " " << v[i] << "\n";
	using mint = modint<>;
	vector<mint> fact;
	fact.push_back(mint(1));
	for(Int i=1; i<=n; ++i) fact.push_back(fact.back() * mint(i));
//	for(size_t i=0; i<=20; ++i)
//		cout << i << " " << fact[i] << "\n";
	mint ans = fact[n];
	Int t = 0;
	for(size_t i=0; i<s.size(); ++i){
		if(v[i] == 0) ++t;
		if(v[i] == 1){
			ans *= mint(t);
			--t;
		}
	}
	t = 0;
	for(size_t i=s.size()-1; i>=0; --i){
		if(v[i] == 2) ++t;
		if(v[i] == 1){
			ans *= mint(t);
			--t;
		}
		if(i == 0) break;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6796