#ABC215E. [ABC215E] Chain Contestant

[ABC215E] Chain Contestant

Score : 500500 points

Problem Statement

AtCoder in another world holds 1010 types of contests called AAC, ..., AJC. There will be NN contests from now on. The types of these NN contests are given to you as a string SS: if the ii-th character of SS is xx, the ii-th contest will be AxxC. AtCoDeer will choose and participate in one or more contests from the NN so that the following condition is satisfied.

  • In the sequence of contests he will participate in, the contests of the same type are consecutive.- Formally, when AtCoDeer participates in xx contests and the ii-th of them is of type TiT_i, for every triple of integers (i,j,k)(i,j,k) such that 1i<j<kx1 \le i < j < k \le x, Ti=TjT_i=T_j must hold if Ti=TkT_i=T_k.

Find the number of ways for AtCoDeer to choose contests to participate in, modulo 998244353998244353. Two ways to choose contests are considered different when there is a contest cc such that AtCoDeer participates in cc in one way but not in the other.

Constraints

  • 1N10001 \le N \le 1000
  • S=N|S|=N
  • SS consists of uppercase English letters from A through J.

Input

Input is given from Standard Input in the following format:

NN

SS

Output

Print the answer as an integer.

4
BGBH
13

For example, participating in the 11-st and 33-rd contests is valid, and so is participating in the 22-nd and 44-th contests. On the other hand, participating in the 11-st, 22-nd, 33-rd, and 44-th contests is invalid, since the participations in ABCs are not consecutive, violating the condition for the triple (i,j,k)=(1,2,3)(i,j,k)=(1,2,3). Additionally, it is not allowed to participate in zero contests. In total, there are 1313 valid ways to participate in some contests.

100
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIEIJEIJIJCGCCFGIEBIHFCGFBFAEJIEJAJJHHEBBBJJJGJJJCCCBAAADCEHIIFEHHBGF
330219020

Be sure to find the count modulo 998244353998244353.