#P1807C. Find and Replace

Find and Replace

No submission language available for this problem.

Description

You are given a string ss consisting of lowercase Latin characters. In an operation, you can take a character and replace all occurrences of this character with 0\texttt{0} or replace all occurrences of this character with 1\texttt{1}.

Is it possible to perform some number of moves so that the resulting string is an alternating binary string^{\dagger}?

For example, consider the string abacaba\texttt{abacaba}. You can perform the following moves:

  • Replace a\texttt{a} with 0\texttt{0}. Now the string is 0b0c0b0\color{red}{\texttt{0}}\texttt{b}\color{red}{\texttt{0}}\texttt{c}\color{red}{\texttt{0}}\texttt{b}\color{red}{\texttt{0}}.
  • Replace b\texttt{b} with 1\texttt{1}. Now the string is 010c010{\texttt{0}}\color{red}{\texttt{1}}{\texttt{0}}\texttt{c}{\texttt{0}}\color{red}{\texttt{1}}{\texttt{0}}.
  • Replace c\texttt{c} with 1\texttt{1}. Now the string is 0101010{\texttt{0}}{\texttt{1}}{\texttt{0}}\color{red}{\texttt{1}}{\texttt{0}}{\texttt{1}}{\texttt{0}}. This is an alternating binary string.

^{\dagger}An alternating binary string is a string of 0\texttt{0}s and 1\texttt{1}s such that no two adjacent bits are equal. For example, 01010101\texttt{01010101}, 101\texttt{101}, 1\texttt{1} are alternating binary strings, but 0110\texttt{0110}, 0a0a0\texttt{0a0a0}, 10100\texttt{10100} are not.

The input consists of multiple test cases. The first line contains an integer tt (1t1001 \leq t \leq 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (1n20001 \leq n \leq 2000) — the length of the string ss.

The second line of each test case contains a string consisting of nn lowercase Latin characters — the string ss.

For each test case, output "YES" (without quotes) if you can make the string into an alternating binary string, and "NO" (without quotes) otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

Input

The input consists of multiple test cases. The first line contains an integer tt (1t1001 \leq t \leq 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (1n20001 \leq n \leq 2000) — the length of the string ss.

The second line of each test case contains a string consisting of nn lowercase Latin characters — the string ss.

Output

For each test case, output "YES" (without quotes) if you can make the string into an alternating binary string, and "NO" (without quotes) otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

Sample Input 1

8
7
abacaba
2
aa
1
y
4
bkpt
6
ninfia
6
banana
10
codeforces
8
testcase

Sample Output 1

YES
NO
YES
YES
NO
YES
NO
NO

Note

The first test case is explained in the statement.

In the second test case, the only possible binary strings you can make are 00\texttt{00} and 11\texttt{11}, neither of which are alternating.

In the third test case, you can make 1\texttt{1}, which is an alternating binary string.