#include <bits/stdc++.h>
using namespace std;
int n, m;
char c[300010];
struct node {
  int v, num;
} a[300010];
int f[3];
int F(char gg) {
  if (gg == 'R') return 0;
  if (gg == 'G') return 1;
  if (gg == 'B') return 2;
}
int d(int x, int y) { return 3 - x - y; }
int jc[300010], njc[300010], inv[300010];
int A(int x, int y) {
  int ans = 1;
  return 1ll * jc[x] * njc[x - y] % 998244353;
}
int main() {
  scanf("%d", &m);
  scanf("%s", c + 1);
  int tot = 1;
  for (int i = 0; i <= 1; i++) jc[i] = njc[i] = inv[i] = 1;
  for (int i = 2; i <= m * 3; i++) {
    inv[i] = 1ll * inv[998244353 % i] * (998244353 - 998244353 / i) % 998244353;
    jc[i] = 1ll * jc[i - 1] * i % 998244353;
    njc[i] = 1ll * njc[i - 1] * inv[i] % 998244353;
  }
  for (int i = 1; i <= m * 3; i++) {
    if (c[i] != c[i + 1] || i == m * 3)
      a[++n] = {F(c[i]), tot}, tot = 1;
    else
      tot++;
  }
  long long ans = 1, now = -1, sum = 0;
  for (int i = 1; i <= n; i++) {
    int n1 = 0, n2 = 0, n3 = 0;
    if (now != -1) {
      if (now == a[i].v) {
        n1 = f[a[i].v];
        if (n1 >= a[i].num) {
          ans = 1ll * ans * A(f[a[i].v], a[i].num) % 998244353;
          f[a[i].v] -= a[i].num;
        } else if (n1 < a[i].num) {
          ans = 1ll * ans * A(n1, n1) % 998244353;
          f[a[i].v] = 0;
          sum += a[i].num - n1;
          now = a[i].v;
        }
      } else {
        n1 = f[a[i].v];
        n2 = sum;
        if (n1 >= a[i].num) {
          ans = 1ll * ans * A(f[a[i].v], a[i].num) % 998244353;
          f[a[i].v] -= a[i].num;
        } else if (n1 + n2 >= a[i].num) {
          ans = 1ll * ans * A(n1, n1) % 998244353 * A(n2, a[i].num - n1) %
                998244353;
          f[d(a[i].v, now)] += a[i].num - n1;
          f[a[i].v] = 0;
          sum -= (a[i].num - n1);
          if (!sum) now = -1;
        } else if (n1 + n2 < a[i].num) {
          ans = 1ll * ans * A(n1, n1) % 998244353 * A(n2, n2) % 998244353;
          f[d(a[i].v, now)] += sum;
          f[a[i].v] = 0;
          sum = a[i].num - n1 - n2;
          now = a[i].v;
        }
      }
    } else {
      n1 = f[a[i].v];
      if (n1 >= a[i].num) {
        ans = 1ll * ans * A(f[a[i].v], a[i].num) % 998244353;
        f[a[i].v] -= a[i].num;
      } else if (n1 < a[i].num) {
        ans = 1ll * ans * A(n1, n1) % 998244353;
        f[a[i].v] = 0;
        sum = a[i].num - n1;
        now = a[i].v;
      }
    }
  }
  cout << 1ll * ans * jc[m] % 998244353;
  return 0;
}
