CF2121B.Above the Clouds

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

Above the Clouds

You are given a string ss of length nn, consisting of lowercase letters of the Latin alphabet. Determine whether there exist three non-empty strings aa, bb, and cc such that:

  • a+b+c=sa + b + c = s, meaning the concatenation^{\text{∗}} of strings aa, bb, and cc equals ss.
  • The string bb is a substring^{\text{†}} of the string a+ca + c, which is the concatenation of strings aa and cc.

^{\text{∗}}Concatenation of strings aa and bb is defined as the string a+b=a1a2apb1b2bqa + b = a_1a_2 \ldots a_pb_1b_2 \ldots b_q, where pp and qq are the lengths of strings aa and bb, respectively. For example, the concatenation of the strings "code" and "forces" is "codeforces".

^{\text{†}}A string aa is a substring of a string bb if aa can be obtained from bb by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

Input

Each test consists of multiple test cases. The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (3n1053 \leq n \leq 10^5) — the length of the string ss.

The second line of each test case contains the string ss of length nn, consisting of lowercase letters of the Latin alphabet.

It is guaranteed that the sum of nn across all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output "Yes" if there exist three non-empty strings aa, bb, and cc that satisfy the conditions, and "No" otherwise.

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

Note

In the first test case, there exist unique non-empty strings aa, bb, and cc such that a+b+c=sa + b + c = s. These are the strings a=a = "a", b=b = "a", and c=c = "a". The concatenation of strings aa and cc equals a+c=a + c = "aa". The string bb is a substring of this string.

In the sixth test case, one can choose a=a = "a", b=b = "ab", and c=c = "b". The concatenation of strings aa and cc equals a+c=a + c = "ab". The string bb is a substring of this string.

In the seventh test case, one can choose a=a = "ab", b=b = "a", and c=c = "ca". The concatenation of strings aa and cc equals a+c=a + c = "abca". The string bb is a substring of this string.

Samples

12
3
aaa
3
aba
3
aab
4
abca
4
abba
4
aabb
5
abaca
5
abcda
5
abcba
6
abcbbf
6
abcdaa
3
abb
Yes
No
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes

在线编程 IDE

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