Problem: Let's call a binary string of length indexed from to paranoid if we can obtain a string of length by performing the following two kinds of operations times in any order :
- Select any substring of that is equal to 01, and then replace it with 1.
- Select any substring of that is equal to 10, and then replace it with 0.For example, if 001, we can select the substring and perform the first operation. So we obtain 01.
You are given a binary string of length indexed from to . Find the number of pairs of integers such that (the substring of from to ) is a paranoid string.
Input Format: The first line contains an integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the size of .
The second line of each test case contains a binary string of characters . ( 0 or 1 for each )
It is guaranteed that the sum of over all test cases doesn't exceed .
Output Format: For each test case, output the number of pairs of integers such that (the substring of from to ) is a paranoid string.
Note: In the first sample, already has length and doesn't need any operations.
In the second sample, all substrings of are paranoid. For the entire string, it's enough to perform the first operation.
In the third sample, all substrings of are paranoid except , because we can't perform any operations on it, and (the entire string).