#include <bits/stdc++.h>
#define MOD 998244353

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

template<int mod>
struct ModInt{
    int x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=mod-p.x)>=mod)x-=mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1LL*x*p.x%mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this*=p.inverse();
        return *this;
    }
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
    ModInt operator-()const{return ModInt(-x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
    bool operator==(const ModInt &p)const{return x==p.x;}
    bool operator!=(const ModInt &p)const{return x!=p.x;}
    explicit operator int() const { return x; }                           // added by QCFium
    ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
    ModInt inverse()const{
        int a=x,b=mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            a-=t*b;
            std::swap(a,b);
            u-=t*v;
            std::swap(u,v);
        }
        return ModInt(u);
    }
    friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
        return os<<p.x;
    }
    friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
        long long x;
        is>>x;
        a=ModInt<mod>(x);
        return (is);
    }
};
typedef ModInt<MOD> mint;


int main() {
	int n = ri();
	n *= 3;
	std::string s;
	std::cin >> s;
	int a[n];
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') a[i] = 0;
		else if (s[i] == 'G') a[i] = 1;
		else a[i] = 2;
	}
	int next[n][3];
	for (int i = 0; i < 3; i++) {
		int cur = n;
		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == i) cur = j;
			next[j][i] = cur;
		}
	}
	
	int cur[8] = { 0 };
	cur[0] = n / 3;
	mint res = 1;
	for (int i = 0; i < n; i++) {
		// std::cerr << i << ":";
		int most = 7 & ~(1 << a[i]);
		if (cur[most]) {
			// std::cerr << "most : " << cur[most] << std::endl;
			res *= cur[most];
			cur[most]--;
			cur[7]++;
		} else {
			int r[2];
			int cnt = 0;
			for (int j = 0; j < 3; j++) if (j != a[i]) r[cnt++] = j;
			
			bool r0 = false;
			bool r1 = false;
			if (cur[1 << r[0]] && cur[1 << r[1]]) {
				// std::cerr << "choose ";
				// choose
				if (next[i][r[1]] > next[i][r[0]]) r1 = true;
				else r0 = true;
			} else if (cur[1 << r[0]]) r0 = true;
			else if (cur[1 << r[1]]) r1 = true;
			else {
				// std::cerr << "new" << std::endl;
				res *= cur[0];
				cur[0]--;
				cur[1 << a[i]]++;
			}
			if (r1) { // choose r[1]
				// std::cerr << r[1] << std::endl;
				res *= cur[1 << r[1]];
				cur[1 << r[1]]--;
				cur[(1 << r[1]) | (1 << a[i])]++;
			} else if (r0) {
				// std::cerr << r[0] << std::endl;
				res *= cur[1 << r[0]];
				cur[1 << r[0]]--;
				cur[(1 << r[0]) | (1 << a[i])]++;
			}
		}
	}
	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 5892