import java.lang.Math.*

private fun readln() = readLine()!!.trim()
private fun readlnInt() = readln().toInt()
private fun readlnStrings() = readln().split(' ')
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }

fun check(A:Long, B:Long, C:Long): Long{
    val s = min(B, C)
    val l = max(B, C)
    if (A <= s) {
        return s - A
    } else if (A <= l){
        return l - A
    } else {
        return 0
    }
}

fun solve() {
    val N = readlnInt()
    val S = readln()
    var cntA = 0L
    var cntB = 0L
    var cntC = 0L
    var ttl = 1L
    val MOD = 998244353
    for (i in 0 until 3*N){
        val ch = S[i]
        if (ch=='R'){
            cntA += 1
            val r = check(cntA, cntB, cntC)
            ttl = ttl * (r+1) % MOD
        } else if (ch=='G') {
            cntB += 1
            val r = check(cntB, cntA, cntC)
            ttl = ttl * (r+1) % MOD
        } else {
            cntC += 1
            val r  = check(cntC, cntA, cntB)
            ttl = ttl * (r+1) % MOD
        }
    }
    for (i in 1..N){
        ttl = ttl * i % MOD
    }
    println(ttl)
}


fun main(args: Array<String>) {
//    val queryNum = readlnInt()
//    for (queryIdx in 1..queryNum) {
//        println("Case #$queryIdx:")
        solve()
//    }
}
