7585: Isomorphic Strings

内存限制:128 MB 时间限制:8 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:26 通过:12

题目描述

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 s of length n. Please check if s is a concatenation of k strings, s1,s2,⋯,sk (k>1), where,

  • k is a divisor of n;

  • s1,s2,…,sk are of equal length: nk;

  • There exists a string t, which is cyclical isomorphic with si for all 1≤i≤k.


Print ''Yes'' if the check is positive, or ''No'' otherwise.

输入格式

The first line contains an integer T (1≤T≤1000), denoting the number of test cases. T cases follow.

  • The first line of each test case contains an integer n (1≤n≤5⋅106).

  • The second line contains a string s of length n consists of lowercase letters only.


It is guaranteed that the sum of n does not exceed 2⋅107.

输出格式

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

输入样例 复制

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

输出样例 复制

No
Yes
No
Yes
No
Yes

分类标签