#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "RGB";
    int K = (int) t.size();
    map<char, int> char_to_int;
    for (int j = 0; j < K; ++j) {
        char_to_int[t[j]] = j;
    }
    vector<vector<int>> colors(K);
    for (int i = 0; i < K * n; ++i) {
        colors[char_to_int[s[i]]].push_back(i);
    }
    vector<int> order(K * n, 0);
    for (int i = 0; i < n; ++i) {
        vector<int> run(K);
        for (int j = 0; j < K; ++j) {
            run[j] = colors[j][i];
        }
        sort(run.begin(), run.end());
        for (int j = 0; j < K; ++j) {
            order[run[j]] = j;
        }
    }
    long long prime = 998244353;
    vector<int> counters(K + 1, 0);
    counters[0] = n;
    long long answer = 1;
    for (int i = 0; i < K * n; ++i) {
        int multiplier = counters[order[i]] - counters[order[i]+1];
        answer = (answer * multiplier) % prime;
        ++counters[order[i]+1];
    }
    cout << answer << endl;
    return 0;
}
