#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[300005] = {}, b[3] = {}, c[3] = {};
    string s;
    cin >> n >> s;
    ll z = 1, u = n, v = 0, w = 0;
    for (int i = 0; i < n + n + n; i++) {
        int x, y, z;
        if (s[i] == 'R') x = 0, y = 1, z = 2;
        else if (s[i] == 'G') x = 1, y = 2, z = 0;
        else x = 2, y = 0, z = 1;
        if (c[x]) c[x]--, a[i] = -1;
        else if (b[y]) b[y]--, c[z]++, a[i] = 0;
        else if (b[z]) b[z]--, c[y]++, a[i] = 0;
        else b[x]++, a[i] = 1;
    }
    //for (int i = 0; i < n + n + n; i++) cout << a[i] << ' ';
    for (int i = 0; i < n + n + n; i++) {
        if (a[i] == 1) z = z * u % 998244353, u--, v++;
        else if (a[i] == 0) z = z * v % 998244353, v--, w++;
        else z = z * w % 998244353, w--;
    }
    cout << z;
    //BBRGRRGRGGRBBGB
    //((.).()(..()).)
    //5 20 40 40 40 120 120 240 480 480 480 960 960 960 960
}
