// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include <cstdlib>  

#include <math.h>

#include <cmath>

#include<cctype>

#include<string>

#include<set>

#include<iomanip>

#include <map>

#include<algorithm>

#include <functional>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<bitset>

#include <deque>

#include <climits>

#include <typeinfo>

#include <utility> 

using namespace std;

using ll = long long;

template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const ll inf = 1LL << 60;

#define all(x) (x).begin(),(x).end()

#define puts(x) cout << x << endl

#define rep(i,m,n) for(ll i = m;i < n;++i)

#define pb push_back

#define fore(i,a) for(auto &i:a)

#define rrep(i,m,n) for(ll i = m;i >= n;--i)



ll mod = 998244353;

ll fact[101010];

int main() {

	ios::sync_with_stdio(false);

	cin.tie(nullptr);



	int N;

	string S;

	cin >> N >> S;

	fact[0] = 1;

	for (ll i = 1; i < 101010; i++) {

		fact[i] = fact[i - 1] * i;

		fact[i] %= mod;

	}



	ll ans = fact[N];

	map<char, int>mp;

	mp['R'] = 0;

	mp['G'] = 0;

	mp['B'] = 0;

	for (int i = 0; i < 3 * N; i++) {

		char c = S[i];

		vector<pair<int, char>>v;

		fore(x, mp)v.pb({x.second,x.first});

		sort(all(v));

		if (mp[c] == v[0].first) {

			if (v[0].first < v[1].first)ans *= v[1].first - v[0].first;

			else if(v[1].first < v[2].first) ans *= v[2].first - v[0].first;

		}

		else if (mp[c] == v[1].first) {

			if (v[1].first < v[2].first)ans *= v[2].first - v[1].first;

		}

		mp[c]++;

		ans %= mod;

	}

	puts(ans);



	return 0;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<cstdio>

#include<cstring>

#include <cstdlib>  

#include <math.h>

#include <cmath>

#include<cctype>

#include<string>

#include<set>

#include<iomanip>

#include <map>

#include<algorithm>

#include <functional>

#include<vector>

#include<climits>

#include<stack>

#include<queue>

#include<bitset>

#include <deque>

#include <climits>

#include <typeinfo>

#include <utility> 

using namespace std;

using ll = long long;

template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const ll inf = 1LL << 60;

#define all(x) (x).begin(),(x).end()

#define puts(x) cout << x << endl

#define rep(i,m,n) for(ll i = m;i < n;++i)

#define pb push_back

#define fore(i,a) for(auto &i:a)

#define rrep(i,m,n) for(ll i = m;i >= n;--i)





ll mod = 998244353;

int main() {

	ios::sync_with_stdio(false);

	cin.tie(nullptr);



	int N;

	string S;

	cin >> N >> S;

	vector<ll>cnt(7);

	cnt[6] = N;

	ll ans = 1;

	for (int i = 0; i < 3*N; i++) {

		int c = S[i];

		if (c == 'R') {

			if (cnt[2]) {

				ans *= cnt[2];

				cnt[2]--;

			}

			else if (cnt[3]) {

				ans *= cnt[3];

				cnt[3]--;

				cnt[0]++;

			}

			else if (cnt[5]) {

				ans *= cnt[5];

				cnt[5]--;

				cnt[1]++;

			}

			else {

				ans *= cnt[6];

				cnt[6]--;

				cnt[4]++;

			}

		}

		else if (c == 'G') {

			if (cnt[1]) {

				ans *= cnt[1];

				cnt[1]--;

			}

			else if (cnt[4]) {

				ans *= cnt[4];

				cnt[4]--;

				cnt[0]++;

			}

			else if (cnt[5]) {

				ans *= cnt[5];

				cnt[5]--;

				cnt[2]++;

			}

			else {

				ans *= cnt[6];

				cnt[6]--;

				cnt[3]++;

			}

		}

		else {

			if (cnt[0]) {

				ans *= cnt[0];

				cnt[0]--;

			}

			else if (cnt[3]) {

				ans *= cnt[3];

				cnt[3]--;

				cnt[2]++;

			}

			else if (cnt[4]) {

				ans *= cnt[4];

				cnt[4]--;

				cnt[1]++;

			}

			else {

				ans *= cnt[6];

				cnt[6]--;

				cnt[5]++;

			}

		}

		ans %= mod;

	}

	puts(ans);



	return 0;

}




// Fastest known solution for this problem: