#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 998244353;
const int MAXN = 3e5+5;

ll mult(ll a, ll b){
    return a * b % MOD;
}
ll binPow(ll a, ll b){
    if(b == 0) return 1;
    if(b & 1) return a * binPow(a, b-1) % MOD;
    return binPow(a * a % MOD, b >> 1);
}
ll inv(ll a){
    return binPow(a, MOD - 2);
}

ll fact[MAXN], invFact[MAXN];
ll factorial(int n){
    if(fact[n] != -1) return fact[n];
    return fact[n] = n * factorial(n-1) % MOD;
}
ll invFactorial(int n){
    if(invFact[n] != -1) return invFact[n];
    return invFact[n] = inv(n) * invFactorial(n-1) % MOD;
}

ll binomial(int n, int k){
    ll num = factorial(n);
    ll den = mult(invFactorial(k), invFactorial(n-k));
    return mult(num, den);
}

ll assign(int &n, int &k){
    ll ret; 
    if(n >= k) ret = mult(factorial(n), invFactorial(n-k));
    else ret = factorial(n);
    
    int x = min(n, k);
    n -= x;
    k -= x;
    return ret;
}

char other(char a, char b){
    if(a == 'R') return (b == 'G' ? 'B' : 'G');
    if(a == 'B') return (b == 'G' ? 'R' : 'G');
    return (b == 'R' ? 'B' : 'R');
}

int n;
char s[MAXN];

ll solve(){

    int i = 0;
    int r = 0, g = 0, b = 0;
    int rem = 0;
    char col = s[0];
    int noBall = n;

    ll ans = 1;

    while(i < 3*n){
        int len = 0;
        while(i + len < 3*n && s[i] == s[i+len]) len++;

        //Make shit happen        
        int cnt = len;

        //Complete if possible
        if(s[i] == 'R')
            ans = mult(ans, assign(r, cnt));
        if(s[i] == 'G')
            ans = mult(ans, assign(g, cnt));
        if(s[i] == 'B')
            ans = mult(ans, assign(b, cnt));

        //Add to the ones that have only one color
        if(s[i] != col){
            char c = other(s[i], col);
            if(c == 'R') r += min(rem, cnt);
            if(c == 'G') g += min(rem, cnt);
            if(c == 'B') b += min(rem, cnt);

            ans = mult(ans, assign(rem, cnt));
        }

        //Give the remaining to people with no balls
        if(cnt){
            rem += cnt;
            col = s[i];
            ans = mult(ans, assign(noBall, cnt));
        }

        i += len;
    }

    return ans;
}

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

    ms(fact, -1);
    ms(invFact, -1);
    fact[0] = invFact[0] = 1;

    ri(n);
    scanf("%s", s);

    printf("%lld\n", solve());

    return 0;
}


Measured memory_bytes: 8320