N = gets.to_i
S = gets.chomp
MOD = 998244353
ans = 1
1.upto(N) do |i|
	ans = ans * i % MOD
end

com = 1
r = []
g = []
b = []
pre = ''
(3 * N).times do |i|
	now = S[i]
	if now == pre 
		if now == 'R'
			r[-1] += 1 if r.size > 0
			r[0] = 1 if r.size == 0
		elsif now == 'G'
			g[-1] += 1 if g.size > 0
			g[0] = 1 if g.size == 0
		else
			b[-1] += 1 if b.size > 0
			b[0] = 1 if b.size == 0
		end
	else
		if now == 'R'
			r.push(1)
		elsif now == 'G'
			g.push(1)
		else
			b.push(1)
		end
	end
	if r.size > 0 && g.size > 0 && b.size > 0
		com = com * r[0] * g[0] * b[0] % MOD
		r[0] -= 1
		g[0] -= 1
		b[0] -= 1
		r.delete_at(0) if r[0] == 0
		g.delete_at(0) if g[0] == 0
		b.delete_at(0) if b[0] == 0
	end
	pre = now
end
puts ans * com % MOD