#include <bits/stdc++.h>
using namespace std;
int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
void Add(int &x, int &y) {
  if (x) x--, y++;
  return;
}
int cnt[10];
char S[300000 + 5];
int main() {
  int n = read();
  scanf("%s", S + 1);
  long long ans = 1;
  for (int i = 1; i <= 3 * n; i++) {
    int opt = (S[i] == 'R' ? 1 : S[i] == 'G' ? 2 : 3);
    if (cnt[7 - opt])
      ans = ans * cnt[7 - opt] % 998244353, cnt[7 - opt]--;
    else if (opt == 1 && (cnt[2] + cnt[3]))
      ans = ans * (cnt[2] + cnt[3]) % 998244353, Add(cnt[2], cnt[4]),
      Add(cnt[3], cnt[5]);
    else if (opt == 2 && (cnt[1] + cnt[3]))
      ans = ans * (cnt[1] + cnt[3]) % 998244353, Add(cnt[1], cnt[4]),
      Add(cnt[3], cnt[6]);
    else if (opt == 3 && (cnt[1] + cnt[2]))
      ans = ans * (cnt[1] + cnt[2]) % 998244353, Add(cnt[1], cnt[5]),
      Add(cnt[2], cnt[6]);
    else
      cnt[opt]++;
  }
  for (int i = 1; i <= n; i++) ans = ans * i % 998244353;
  printf("%lld\n", ans);
  return 0;
}
