using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        const int M = 998244353;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            long onlyR = 0;
            long onlyG = 0;
            long onlyB = 0;
            long RG = 0;
            long RB = 0;
            long GB = 0;
            long noball = N -1;


            long ans = N;
            switch(s[0])
            {
                case 'R': onlyR++; break;
                case 'G': onlyG++; break;
                case 'B': onlyB++; break;
            }


            for (int i = 1; i < N * 3; i++)
            {
                Char c = s[i];

                switch(c)
                {
                    case 'R':
                        if (GB == 0)
                        {
                            if(onlyG != 0)
                            {
                                ans *= onlyG;
                                RG++;
                                onlyG--;
                            }
                            else if(onlyB != 0)
                            {
                                ans *= onlyB;
                                RB++;
                                onlyB--;
                            }
                            else
                            {
                                ans *= noball;
                                noball--;
                                onlyR++;
                            }
                        }
                        else
                        {
                            ans *= GB;
                            GB--;
                        }
                        break;

                    case 'G':
                        if (RB == 0)
                        {
                            if(onlyR != 0)
                            {
                                ans *= onlyR;
                                onlyR--;
                                RG++;
                            }
                            else if(onlyB != 0)
                            {
                                ans *= onlyB;
                                GB++;
                                onlyB--;
                            }
                            else
                            {
                                ans *= noball;
                                noball--;
                                onlyG++;
                            }
                        }
                        else
                        {
                            ans *= RB;
                            RB--;
                        }
                        break;

                    case 'B':
                        if (RG == 0)
                        {
                            if (onlyR != 0)
                            {
                                ans *= onlyR;
                                onlyR--;
                                RB++;
                            }
                            else if (onlyG != 0)
                            {
                                ans *= onlyG;
                                GB++;
                                onlyG--;
                            }
                            else
                            {
                                ans *= noball;
                                noball--;
                                onlyB++;
                            }
                        }
                        else
                        {
                            ans *= RG;
                            RG--;
                        }
                        break;
                }

                ans %= M;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13920