CF2200C.Specialty String

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Specialty String

AksLolCoding is playing a game on a string ss of length nn. Initially, ss contains only lowercase Latin characters.

In one turn, AksLolCoding can choose any pair of integers (i,j)(i,j) such that:

  • 1i<jn1 \leq i \lt j \leq n;
  • si=sjs_i = s_j \neq *; and
  • sk=s_k = * for all i<k<ji \lt k \lt j.

If no such i,ji,j exists, then the game ends. Otherwise, AksLolCoding sets si:=s_i:=* and sj:=s_j:=*.

Once the game ends, AksLolCoding wins if and only if every character in ss is equal to *. Determine if it is possible for AksLolCoding to win.

Note: * represents ASCII character 42.

Input

The first line contains an integer tt (1t1001 \leq t \leq 100), the number of test cases.

The first line of each test case contains an integer nn (1n50001 \leq n \leq 5000), the length of the string.

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

The sum of nn over all test cases does not exceed 50005000.

Output

Output the answer to each test case on its own line. If AksLolCoding can win, output "YES" (without quotes). Else, output "NO" (without quotes).

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

In the first test case, it can be shown that it is impossible for AksLolCoding to win.

In the second test case, AksLolCoding can win by making the following moves: llmllm \rightarrow llm\*\*m \rightarrow \*\*m\*\*m \rightarrow \*\*\*\*\*\*

In the third test case, AksLolCoding can win by making the following moves: uwuuwu \rightarrow uw\*\*wu \rightarrow u\*\*\*\*u \rightarrow \*\*\*\*\*\*

Samples

6
1
a
6
llmllm
6
uwuuwu
6
byebye
6
oooioi
12
siixxsevvenn
NO
YES
YES
NO
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验