#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)3e5 + 10;
const int MOD = 998244353;
int col[N];
int cnt[8];

int main(){
  fastIO;
  int n;
  cin >> n;
  char s;
  int ans = 1;
  bool ok;
  cnt[0]=n;
  for(int i = 1; i <= 3 * n; i ++ ){
    cin >> s;
    if(s == 'R')
      col[i]=0;
    else if(s == 'G')
      col[i]=1;
    else
      col[i]=2;
    ok = false;
    for(int j = 6; j >= 0; j -- ){
      if((j & (1 << col[i])) == 0 && cnt[j] > 0){
        ok=true;
        ans = (ans * 1ll * cnt[j]) % MOD;
        cnt[j]--;
        cnt[(j|(1<<col[i]))]++;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}