#include <bits/stdc++.h>

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

/// Author: @mathalex
namespace modint {
    static const int MODx = 998244353;

    struct mint {
        int a = 0;

        mint() {}

        mint(int a) : a(a) {}

        mint operator+(const mint& b) const {
            int res = a + b.a;
            if (res >= MODx) {
                res -= MODx;
            }
            return res;
        }

        void operator+=(const mint& b) {
            a += b.a;
            if (a >= MODx) {
                a -= MODx;
            }
        }

        mint operator-(const mint& b) const {
            int res = a - b.a;
            if (res < 0) {
                res += MODx;
            }
            return res;
        }

        void operator-=(const mint& b) {
            a -= b.a;
            if (a < 0) {
                a += MODx;
            }
        }

        mint operator*(const mint& b) const {
            return (ll) a * b.a % MODx;
        }

        void operator*=(const mint& b) {
            a = (ll) a * b.a % MODx;
        }

        int get() const {
            return a;
        }
    };

    mint fpow(mint a, int p) {
        mint x = 1;
        while (p) {
            if (p & 1) {
                x *= a;
            }
            a *= a;
            p >>= 1;
        }
        return x;
    }

    istream& operator>>(istream& in, mint& a) {
        return (in >> a.a);
    }

    ostream& operator<<(ostream& out, const mint& a) {
        return (out << a.a);
    }
}

using namespace modint;

mint ans = 1;

void prc(vector<pii>& ev) {
    vector<mint> cnt(3);
    for (pii& el : ev) {
        //cout << el.f << ' ' << el.s << endl;
        if (el.s > 0) {
            cnt[el.s - 1] += 1;
        } else {
            ans *= cnt[-el.s - 1];
            cnt[-el.s - 1] -= 1;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> r, g, b;
    for (int i = 0; i < n * 3; ++i) {
        if (s[i] == 'R') {
            r.eb(i);
        } else if (s[i] == 'G') {
            g.eb(i);
        } else {
            b.eb(i);
        }
    }
    vector<pii> eva, evb;
    for (int i = 0; i < n; ++i) {
        vector<pii> t = {{r[i], 1}, {g[i], 2}, {b[i], 3}};
        sort(all(t));
        eva.eb(t[0].f, t[0].s);
        eva.eb(t[1].f, -t[0].s);
        evb.eb(t[2].f, t[2].s);
        evb.eb(t[1].f, -t[2].s);
    }
    sort(all(eva));
    sort(rall(evb));
    prc(eva);
    prc(evb);
    for (int i = 1; i <= n; ++i) {
        ans *= i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5768