#agc055d. [agc055_d]ABC Ultimatum

[agc055_d]ABC Ultimatum

Problem Statement

Let's call a string TT of length 3N3N, containing exactly NN letters A, NN letters B, and NN letters C, good, if it can be split into NN (not necessarily contiguous) subsequences of length 33, so that the letters from each subsequence form ABC, BCA, or CAB.

You are given a string SS of length 3N3N, consisting of characters A, B, C, and ?. Count the number of ways to replace each ? with one of A, B, and C, so that the resulting string is good. As this number can be very large, output it modulo 998244353998244353.

Constraints

  • 1leNle151\\le N \\le 15.
  • SS is a string of length 3N3N, consisting of A, B, C, and ?.

Input

Input is given from Standard Input in the following format:

NN SS

Output

Print the answer modulo 998244353998244353.


Sample Input 1

1
???

Sample Output 1

3

There are 33 good strings you can obtain: ABC, BCA, and CAB.


Sample Input 2

2
AA????

Sample Output 2

2

There are 22 good strings you can obtain: AABBCC and AABCBC.


Sample Input 3

3
?A?A?A?A?

Sample Output 3

0

It's impossible to obtain a good string, as there are already 44 A's.


Sample Input 4

9
?????????A??B??C???????????

Sample Output 4

331653164