CF1766B.Notepad#

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

Notepad#

You want to type the string ss, consisting of nn lowercase Latin letters, using your favorite text editor Notepad#.

Notepad# supports two kinds of operations:

  • append any letter to the end of the string;
  • copy a continuous substring of an already typed string and paste this substring to the end of the string.

Can you type string ss in strictly less than nn operations?

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) — the length of the string ss.

The second line contains a string ss, consisting of nn lowercase Latin letters.

The sum of nn doesn't exceed 21052 \cdot 10^5 over all testcases.

Output

For each testcase, print "YES" if you can type string ss in strictly less than nn operations. Otherwise, print "NO".

Note

In the first testcase, you can start with typing "codef" (55 operations), then copy "o" (11 operation) from an already typed part, then finish with typing "rces" (44 operations). That will be 1010 operations, which is not strictly less than nn. There exist other ways to type "codeforces". However, no matter what you do, you can't do less than nn operations.

In the second testcase, you can type "labac" (55 operations), then copy "aba" (11 operation), finishing the string in 66 operations.

Samples

6
10
codeforces
8
labacaba
5
uohhh
16
isthissuffixtree
1
x
4
momo
NO
YES
NO
YES
NO
YES

在线编程 IDE

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