#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

constexpr long long order_of_field = 998244353;

//element of Z/pZ
class Modulo
{
private:
    long long p;
    long long n;
public:
    Modulo(): p(order_of_field), n(1) {}
    Modulo(long long n0);
    
    bool operator==(const Modulo rhs) const{return n == rhs.n;}
    Modulo& operator+=(const long long rhs);
    Modulo& operator+=(const Modulo& rhs);
    Modulo& operator*=(const long long rhs);
    Modulo& operator*=(const Modulo& rhs);
    Modulo& operator-=(const long long rhs);
    Modulo& operator-=(const Modulo& rhs);
    Modulo pow(const long long k) const;
    Modulo inverse() const;
    Modulo& operator/=(const long long rhs);
    Modulo& operator/=(const Modulo& rhs);
    long long get() const{return n;};
};

const Modulo operator+(const Modulo &lhs, const Modulo &rhs);
const Modulo operator+(const Modulo &lhs, const long long rhs);
const Modulo operator+(const long long lhs, const Modulo &rhs);
const Modulo operator*(const Modulo &lhs, const Modulo &rhs);
const Modulo operator*(const Modulo &lhs, const long long rhs);
const Modulo operator*(const long long lhs, const Modulo &rhs);

//constructor
Modulo::Modulo(long long n0)
{
    p = order_of_field;
    n = n0 >= 0 ? n0 % p : (p - (-n0 % p)) % p;
}

//operator +=
inline Modulo& Modulo::operator+=(const long long rhs)
{
    long long rhs1 = rhs >= 0 ? rhs % p : (p - (-rhs % p)) % p;
    n = (n + rhs1) % p;
    return *this;
}

inline Modulo& Modulo::operator+=(const Modulo& rhs)
{
    (*this) += rhs.n;
    return *this;
}

//operator *=
inline Modulo& Modulo::operator*=(const long long rhs)
{
    long long rhs1 = rhs >= 0 ? rhs % p : (p - (-rhs % p)) % p;
    n = (n * rhs1) % p;
    return *this;
}

inline Modulo& Modulo::operator*=(const Modulo& rhs)
{
    (*this) *= rhs.n;
    return *this;
}

//operator -=
inline Modulo& Modulo::operator-=(const long long rhs)
{
    return *this += -rhs;
}

inline Modulo& Modulo::operator-=(const Modulo& rhs)
{
    (*this) -= rhs.get();
    return *this; 
}

//(*this)**k
Modulo Modulo::pow(const long long k) const
{
    if(k == 0) return 1;
    if(k == 1) return n;
    long long k1 = k >= 0 ? k % (p-1) : ((p-1) - (-k % (p-1))) % (p-1);
    Modulo r = pow(k1/2);
    if(k1 % 2 == 0) return r * r;
    else return r * r * n; 
}

//(*this)**(-1)
Modulo Modulo::inverse() const
{
    return pow(-1);
}

//operator /=
inline Modulo& Modulo::operator/=(const long long rhs)
{
    Modulo inv = rhs;
    inv = inv.inverse();
    return *this *= inv;
}

inline Modulo& Modulo::operator/=(const Modulo& rhs)
{
    (*this) /= rhs.get();
    return *this; 
}

//operator +
const Modulo operator+(const Modulo &lhs, const Modulo &rhs)
{
    return Modulo(lhs.get()) += rhs;
}

const Modulo operator+(const Modulo &lhs, const long long rhs)
{
    return Modulo(lhs.get()) += rhs;
}

const Modulo operator+(const long long lhs, const Modulo &rhs)
{
    return Modulo(lhs) += rhs;
}

//operator *
const Modulo operator*(const Modulo &lhs, const Modulo &rhs)
{
    return Modulo(lhs.get()) *= rhs;
}

const Modulo operator*(const Modulo &lhs, const long long rhs)
{
    return Modulo(lhs.get()) *= rhs;
}

const Modulo operator*(const long long lhs, const Modulo &rhs)
{
    return Modulo(lhs) *= rhs;
}

//operator -
const Modulo operator-(const Modulo &lhs, const Modulo &rhs)
{
    return Modulo(lhs.get()) -= rhs;
}

const Modulo operator-(const Modulo &lhs, const long long rhs)
{
    return Modulo(lhs.get()) -= rhs;
}

const Modulo operator-(const long long lhs, const Modulo &rhs)
{
    return Modulo(lhs) -= rhs;
}

//operator /
const Modulo operator/(const Modulo &lhs, const Modulo &rhs)
{
    return Modulo(lhs.get()) /= rhs;
}

const Modulo operator/(const Modulo &lhs, const long long rhs)
{
    return Modulo(lhs.get()) /= rhs;
}

const Modulo operator/(const long long lhs, const Modulo &rhs)
{
    return Modulo(lhs) /= rhs;
}

//very very useful functions
//n**k
Modulo pow(Modulo n, long long k)
{
    Modulo tmp = n;
    tmp = tmp.pow(k);
    return tmp;
}

//n!
void fact_set(long long *base, int size)
{
    Modulo m = 1;
    if(size >= 0) base[0] = 1;
    for(int i=1; i<size; i++){
        m *= i;
        base[i] = m.get();
    }
}

//nCk
Modulo comb(long long n, long long k, long long *fact)
{
    Modulo a = fact[n];
    Modulo b = fact[k];
    Modulo c = fact[n-k];
    return a / b / c;
}

int main()
{
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;

    std::vector<int> R, G, B;
    for(int i=0; i<3*N; i++){
        if(S[i] == 'R') R.push_back(i);
        else if(S[i] == 'G') G.push_back(i);
        else B.push_back(i);
    }
    std::vector<int> a, b, c;
    for(int i=0; i<N; i++){
        std::vector<int> tmp;
        tmp.push_back(R[i]);
        tmp.push_back(G[i]);
        tmp.push_back(B[i]);
        std::sort(tmp.begin(), tmp.end());
        a.push_back(tmp[0]);
        b.push_back(tmp[1]);
        c.push_back(tmp[2]);
    }

    long long fact[N+1];
    fact_set(fact, N+1);
    Modulo ans = fact[N];
    int j = 0;
    for(int i=0; i<N; i++){
        while(j < N && a[j] < b[i]) j++;
        ans *= (j-i);
        // printf("ans *= %d\n", j-i);
    }
    j = N - 1;
    for(int i=N-1; i>=0; i--){
        while(j >= 0 && b[i] < c[j]) j--;
        ans *= (i-j);
        // printf("ans *= %d\n", i-j);
    }
    std::cout << ans.get() << std::endl;
}

Measured memory_bytes: 4348