#P7852. Isomorphic Strings

Isomorphic Strings

Isomorphic Strings

Problem Description

It is preferrable to read the pdf statment. Two strings are called cyclical isomorphic if one can rotate one string to get another one. 'Rotate' here means ''to take some consecutive chars (maybe none) from the beginning of a string and put them back at the end of the string in the same order''. For example, string ''abcde'' can be rotated to string ''deabc''. Now that you know what cyclical isomorphic is, Cuber QQ wants to give you a little test. Here is a string ss of length nn. Please check if ss is a concatenation of kk strings, s1,s2,,sks_1,s_2,\cdots,s_k (k>1k>1), where, kk is a divisor of nn; s1,s2,,sks_1,s_2,\ldots,s_k are of equal length: nk\frac{n}{k}; There exists a string tt, which is cyclical isomorphic with sis_i for all 1ik1\le i\le k. Print ''Yes'' if the check is positive, or ''No'' otherwise.

Input

The first line contains an integer TT (1T10001\le T\le 1000), denoting the number of test cases. TT cases follow. The first line of each test case contains an integer nn (1n51061\le n \le 5 \cdot 10^6). The second line contains a string ss of length nn consists of lowercase letters only. It is guaranteed that the sum of nn does not exceed 21072\cdot 10^7.

Output

For each test case, output one line containing ''Yes'' or ''No'' (without quotes).

Sample Input

6
1
a
2
aa
3
aab
4
abba
6
abcbcc
8
aaaaaaaa

Sample Output

No
Yes
No
Yes
No
Yes

Source

2020 Multi-University Training Contest 8