#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int N;
string S;
int main(void){
    cin >> N;
    cin >> S;

    ll count = 1;
    int L[10];
    L[0] = N;
    for(int i=1;i<10;i++) L[i] = 0;
    for(int i=0;i < S.length();i++){
        count %= 998244353;
        if(S[i] == 'G'){
            if(L[6] > 0){
                count *= (L[6] + L[8]);
                L[6] -= 1;
            }else if(L[8] > 0){
                count *= L[8];
                L[8] -= 1;
            }else if(L[4] > 0){
                count *= L[4];
                L[4] -= 1;
                L[5] += 1;
            }else if(L[7] > 0){
                count *= L[7];
                L[7] -= 1;
                L[9] += 1;
            }else{
                count *= L[0];
                L[0] -= 1;
                L[1] += 1;
            }
        }
        if(S[i] == 'B'){
            if(L[3] > 0){
                count *= (L[3] + L[9]);
                L[3] -= 1;
            }else if(L[9] > 0){
                count *= L[9];
                L[9] -= 1;
            }else if(L[1] > 0){
                count *= L[1];
                L[1] -= 1;
                L[2] += 1;
            }else if(L[7] > 0){
                count *= L[7];
                L[7] -= 1;
                L[8] += 1;
            }else{
                count *= L[0];
                L[0] -= 1;
                L[4] += 1;
            }
        }
        if(S[i] == 'R'){
            if(L[2] > 0){
                count *= (L[2] + L[5]);
                L[2] -= 1;
            }else if(L[5] > 0){
                count *= L[5];
                L[5] -= 1;
            }else if(L[1] > 0){
                count *= L[1];
                L[1] -= 1;
                L[3] += 1;
            }else if(L[4] > 0){
                count *= L[4];
                L[4] -= 1;
                L[6] += 1;
            }else{
                count *= L[0];
                L[0] -= 1;
                L[7] += 1;
            }
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 900