Given a string consisting of characters , , and .
In one operation, you are allowed to choose two adjacent elements of the string s_is_{i+1} that are in the following order: , , or , and swap them.
Find the maximum number of consecutive operations that can be performed on the string .
In this problem, each test contains several sets of input data. You need to solve the problem independently for each such set.
The first line contains one integer (1\le T\le 10^5) — the number of sets of input data. The description of the input data sets follows.
In the first line of each input data set, there is one integer (1 \le n \le 10^6) — the length of the string .
In the second line of each input data set, there is a string of length , consisting of characters , , and .
It is guaranteed that the sum of across all input data sets of a single test does not exceed 10^6.
For each set of input data, output on a separate line one integer — the maximum number of consecutive operations that can be performed on the string .
Example 1
In the first set of input data from the first example, no more than consecutive operations can be performed on the string ABCCA. One example of how consecutive operations can be performed is [ABCCA BACCA, BACCA BACAC, BACAC BAACC].
Let be the sum of over all input data sets of one test.
( points): the answer is equal to or ;
( points): n \le 3;
( points): s_i \ne \texttt{C} for 1 \le i \le n;
( points): has the form \texttt{AA}\ldots \texttt{AABB}\ldots \texttt{BBCC}\ldots \texttt{CC} (that is, x \cdot \texttt{A} + y \cdot \texttt{B} + z \cdot \texttt{C} for certain positive , , );
( points): s_is_{i+1} \ne \texttt{CA} for 1 \le i < n;
( points): T = 1, n \le 12;
( points): n \le 12;
( points): K \le 2000;
( points): without additional constraints.