//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

const int mod = 998244353;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this); return res/=a;}
};
mint mod_pow(long long p,long long q){mint res = p;return res.pow(q);}

int balls[3];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int n;cin >> n;
    string s;cin >> s;
    mint ans = 1;
    int M,m;
    map<char,int> col;
    col['R'] = 0,col['G'] = 1,col['B'] = 2;
    for(int i = 0;i < 3*n;i++){
        int num = col[s[i]];
        int cnt = 0;
        for(int i = 0;i < 3;i++)cnt += (balls[i] > 0);
        bool two = (cnt == 2);
        if(balls[num] == max({balls[0],balls[1],balls[2]})){
            balls[num]++;
        }else if(balls[num] == 0 and two){
            if(num == 0){
                if(balls[1] >= balls[2]){
                    ans *= (mint)balls[2];
                    balls[1]--;
                    balls[2]--;
                }else{
                    ans *= (mint)balls[1];
                    balls[2]--;
                    balls[1]--;
                }
            }else if(num == 1){
                if(balls[0] >= balls[2]){
                    ans *= (mint)balls[2];
                    balls[0]--;
                    balls[2]--;
                }else{
                    ans *= (mint)balls[0];
                    balls[0]--;
                    balls[2]--;
                }
            }else{
                if(balls[1] >= balls[0]){
                    ans *= (mint)balls[0];
                    balls[1]--;
                    balls[0]--;
                }else{
                    ans *= (mint)balls[1];
                    balls[1]--;
                    balls[0]--;
                }
            }
        }else{
            if(num == 0){
               if(balls[1] >= balls[2]){
                   ans *= (mint)(balls[1] - balls[0]);
                   balls[0]++;
               }else{
                   ans *= (mint)(balls[2] - balls[0]);
                   balls[0]++;
               } 
            }else if(num == 1){
               if(balls[0] >= balls[2]){
                   ans *= (mint)(balls[0] - balls[1]);
                   balls[1]++;
               }else{
                   ans *= (mint)(balls[2] - balls[1]);
                   balls[1]++;
               } 
            }else{
               if(balls[1] >= balls[0]){
                   ans *= (mint)(balls[1] - balls[2]);
                   balls[2]++;
               }else{
                   ans *= (mint)(balls[0] - balls[2]);
                   balls[2]++;
               } 
            }
        }
    }
    for(int i = 1;i <= n;i++)ans *= (mint)i;
    cout << ans.x << '\n';
    return 0;
}
/*
 * ちょっと待って！
 * そのコード本当に提出して大丈夫？
 * たくさんのコーナーケースがあるよ！
 * 君の注意力は大したことないよ！
 * WAを出すと君は冷静さを失うよ！
 * */


Measured memory_bytes: 720