#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE



namespace algolib {
namespace NT {

template <typename Int>
inline std::tuple<Int, Int, Int> euclid(Int a, Int b) {
    Int r0 = a, s0 = 1, t0 = 0;
    Int r1 = b, s1 = 0, t1 = 1;
    Int q, rtmp, stmp, ttmp;
    while (r1) {
        q = r0 / r1;
        rtmp = r0 - q*r1, stmp = s0 - q*s1, ttmp = t0 - q*t1;
        r0 = r1, s0 = s1, t0 = t1;
        r1 = rtmp, s1 = stmp, t1 = ttmp;
    }
    return {r0, s0, t0};
}

template <typename Int>
inline Int gcd(Int a, Int b) {
    return std::get<0>(euclid(a, b));
}

template <typename Int>
inline Int lcm(Int a, Int b) {
    return a/gcd(a, b)*b;
}

template <typename Int>
inline auto factor(Int n) {
    std::vector<std::pair<Int, int>> ret;
    for (Int i = 2; i <= n; ++i) {
        int ct = 0;
        while (n % i == 0) {
            n /= i;
            ++ct;
        }
        if (ct) ret.push_back({i, ct});
    }
    return ret;
}

template <typename Int>
inline Int pow(Int n, int64_t k) {
    Int res = 1;
    for (int x = 1; x <= k; x <<= 1) {
        if (k & x) res *= n;
        n *= n;
    }
    return res;
}
/*
template <typename Int>
inline Int totient(Int n) {
    auto v = factor(n);
    Int res = 1;
    for (const auto& [p, k] : v) {
        res *= pow(p, k) - pow(p, k-1);
    }
    return res;
}

template <typename Int>
inline int moebius(Int n) {
    auto v = factor(n);
    int res = 1;
    for (const auto& [p, k] : v) {
        if (k > 1) return 0;
        res *= -1;
    }
    return res;
}

template <typename Int>
inline Int sigma(Int n, int x = 1) {
    auto v = factor(n);
    Int res = 1;
    for (const auto& [p, k] : v) {
        res *= (pow(p, (k+1)*x) - 1) / (pow(p, x) - 1);
    }
    return res;
}
*/

}
}

namespace algolib {
namespace NT {

template <int M>
struct Modulo {
    static const int MOD = M;
    int val;
    Modulo() : val(0) {}
    Modulo(int64_t val) : val((val % M + M) % M) {}
    Modulo& operator+=(const Modulo& rhs) { return *this = val + rhs.val; }
    Modulo operator+() const { return +val; }
    Modulo operator-() const { return -val; }
    Modulo& operator-=(const Modulo& rhs) { return *this = *this + (-rhs); }
    Modulo& operator*=(const Modulo& rhs) { return *this = 1LL * val * rhs.val; }
    Modulo inv() const {
        //auto [d, x, _] = euclid(val, M);
        //assert(d == 1 && "val should be coprime to M.");
        return get<1>(euclid(val, M));
    }
    Modulo pow(int64_t k) const {
        if (k < 0) return inv().pow(-k);
        return NT::pow(*this, k);
    }
    Modulo& operator/=(const Modulo& rhs) { return *this *= rhs.inv(); }
    Modulo& operator++() { return *this += 1; }
    Modulo operator++(int) { int tmp = val; ++*this; return tmp; }
    Modulo& operator--() { return *this -= 1; }
    Modulo operator--(int) { int tmp = val; --*this; return tmp; }
    friend Modulo operator+(Modulo lhs, const Modulo& rhs) { return lhs += rhs; }
    friend Modulo operator-(Modulo lhs, const Modulo& rhs) { return lhs -= rhs; }
    friend Modulo operator*(Modulo lhs, const Modulo& rhs) { return lhs *= rhs; }
    friend Modulo operator/(Modulo lhs, const Modulo& rhs) { return lhs /= rhs; }
    friend bool operator==(const Modulo& lhs, const Modulo& rhs) { return lhs.val == rhs.val; }
    friend bool operator!=(const Modulo& lhs, const Modulo& rhs) { return lhs.val != rhs.val; }
    friend std::istream& operator>>(std::istream& is, Modulo& x) { int64_t n; is >> n; x = Modulo(n); return is; }
    friend std::ostream& operator<<(std::ostream& os, const Modulo& x) { return os << x.val; }
};

/*
// TODO make this use Modulo somehow (need to understand C++ polymorphism/OOP better
// to make it work).
//
// I'm imagining something like Modulo<M> : ModuloBase. Would then have to either cast
// or check compatibility for operations at runtime which is kinda ugly.
template <typename Int>
inline Int CRT(const std::vector<std::pair<Int, Int>>& remainders) {
    Int totmod = 1;
    for (const auto& [_, modulus] : remainders) totmod *= modulus;
    Int res = 0;
    for (const auto& [rem, modulus] : remainders) {
        Int term = rem;
        for (const auto& [_, mod] : remainders) if (mod != modulus) {
            auto [d, modinv, _] = euclid(mod, modulus);
            assert(d == 1);
            term = (((term * mod) % totmod) * modinv) % totmod;
        }
        res = (res + term) % totmod;
    }
    return res;
}*/

}
}

using Mod = algolib::NT::Modulo<998244353>;

template <typename It>
Mod countMatchings(int N, It a, It b) {
    Mod res = 1;
    for (int i = 0, j = 0; i < N; ++i) {
        while (j < N && b[j] < a[i]) ++j;
        res *= j - i;
    }
    return res;
}

Mod solve(int N, const string& S) {
    vector<int> RGB[3];
    REP(c, 3) RGB[c].reserve(N);
    REP(i, 3*N) {
        int c = S[i] == 'R' ? 0 : (S[i] == 'G' ? 1 : 2);
        RGB[c].push_back(i);
    }

    vector<int> sorted[3];
    REP(wh, 3) sorted[wh].reserve(N);
    REP(i, N) {
        int ix[3] = {RGB[0][i], RGB[1][i], RGB[2][i]};
        sort(ix, ix+3);
        REP(wh, 3) sorted[wh].push_back(ix[wh]);
    }

    //debug(sorted[0], sorted[1], sorted[2]);
    Mod ans = countMatchings(N, sorted[1].begin(), sorted[0].begin())
        * countMatchings(N, sorted[2].begin(), sorted[1].begin());
    FOR(k, 1, N+1) ans *= k;
    return ans;

    //debug(RGB[0], RGB[1], RGB[2]);
    // Min cost:
    /*
    ll ans = 0;
    REP(i, N) {
        int mn = min(RGB[0][i], min(RGB[1][i], RGB[2][i]));
        int mx = max(RGB[0][i], max(RGB[1][i], RGB[2][i]));
        ans += mx - mn;
    }
    return ans;
    */
}

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

    int N; cin >> N;
    string S; cin >> S;

    cout << solve(N, S) << '\n';

    return 0;
}


Measured memory_bytes: 3092