#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
struct COMB
{
    int L;
    vll kaijo, gyaku;
    ll mod;
    void __init__(int sz, ll md)
    {
        L = sz;
        mod = md;
        kaijo.resize(L + 1, 0);
        gyaku.resize(L + 1, 0);
        kaijo[0] = 1;
        repf(i, 1, L + 1)
            kaijo[i] = (kaijo[i - 1] * i) % mod;
        gyaku[L] = powmod(kaijo[L], mod - 2, mod);
        rep(i, L)
            gyaku[L - 1 - i] = gyaku[L - i] * (L - i) % mod;
    }
    ll powmod(ll x, ll y, ll mod)
    {
        ll ans = 1;
        while (y > 0)
        {
            if (y & 1)
            {
                ans *= x;
                ans %= mod;
            }
            x = x * x % mod;
            y >>= 1;
        }
        return ans;
    }

    ll calc(int n, int k)
    {
        if (n > L)
            return -1;
        return (((kaijo[n] * gyaku[k]) % mod) * gyaku[n - k]) % mod;
    }
    ll kai(int i)
    {
        return kaijo[i];
    }
    ll gya(int i)
    {
        return gyaku[i];
    }
};
void chmin(ll& a,ll b){
    a = min(a, b);
}
void chmax(ll& a,ll b){
    a = max(a, b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    COMB comb;
    comb.__init__( n, MOD);
    int r,g,b,rg,gb,br;
    r = g = b = rg = gb = br = 0;
    ll ans = comb.kai(n);
    rep(i,3*n){
        if (s[i]=='R'){
            if (gb>0){
                ans=(ans*gb)%MOD;
                gb--;
            }
            else if (g>0){
                ans = (ans * g) % MOD;
                g--;
                rg++;
            }
            else if (b>0){
                ans = (ans * b) % MOD;
                b--;
                br++;
            }
            else{
                r++;
            }
        }
        if (s[i]=='G'){
            if (br>0){
                ans = (ans * br) % MOD;
                br--;
            }
            else if (r > 0)
            {
                ans = (ans * r) % MOD;
                r--;
                rg++;
            }
            else if (b > 0)
            {
                ans = (ans * b) % MOD;
                b--;
                gb++;
            }
            else
            {
                g++;
            }
        }
        if (s[i]=='B')
        {
            if (rg > 0)
            {
                ans = (ans * rg) % MOD;
                rg--;
            }
            else if (r > 0)
            {
                ans = (ans * r) % MOD;
                r--;
                br++;
            }
            else if (g > 0)
            {
                ans = (ans * g) % MOD;
                g--;
                gb++;
            }
            else
            {
                b++;
            }
        }
    }
    cout << ans << ENDL;
}

Measured memory_bytes: 2196