#arc163a. [arc163_a]Divide String

[arc163_a]Divide String

Problem Statement

You are given a string SS of length NN consisting of lowercase English letters. Determine whether it is possible to divide SS into two or more consecutive substrings so that they are strictly increasing in lexicographical order.

To be precise, determine whether there is a sequence of strings t=(t1,t2,dots,tk)t=(t_1,t_2,\\dots,t_k) that satisfies all of the following conditions.

  • The length of the sequence kk is at least 22.

  • tit_i is not empty. (1leilek1 \\le i \\le k)

  • Concatenating t1,t2,dots,tkt_1,t_2,\\dots,t_k in this order results in SS.

  • tit_i is lexicographically smaller than ti+1t_{i+1} for every integer ii such that 1lei<k1 \\le i < k.

You are given TT test cases. Find the answer for each of them.

What is lexicographical order?

A string S=S1S2ldotsSSS = S_1S_2\\ldots S_{|S|} is said to be lexicographically smaller than a string T=T1T2ldotsTTT = T_1T_2\\ldots T_{|T|} if either 1. or 2. below holds. Here, S|S| and T|T| represent the lengths of SS and TT, respectively.

  1. SltT|S| \\lt |T| and S1S2ldotsSS=T1T2ldotsTSS_1S_2\\ldots S_{|S|} = T_1T_2\\ldots T_{|S|}.
  2. There is an integer 1leqileqminlbraceS,Trbrace1 \\leq i \\leq \\min\\lbrace |S|, |T| \\rbrace such that both of the following hold.
    • S1S2ldotsSi1=T1T2ldotsTi1S_1S_2\\ldots S_{i-1} = T_1T_2\\ldots T_{i-1}.
    • The character SiS_i comes before TiT_i in alphabetical order.

Constraints

  • 1leTle20001 \\le T \\le 2000
  • 2leNle20002 \\le N \\le 2000
  • SS is a string of length NN consisting of lowercase English letters.
  • The sum of NN over all test cases in a single input does not exceed 20002000.

Input

The input is given from Standard Input in the following format:

TT mathrmcase1\\mathrm{case}_1 mathrmcase2\\mathrm{case}_2 vdots\\vdots mathrmcaseT\\mathrm{case}_T

Here, mathrmcasei\\mathrm{case}_i represents the ii-th test case. Each test case is given in the following format:

NN SS

Output

Print TT lines.

The ii-th line (1leileT)(1 \\le i \\le T) should contain Yes if it is possible to divide SS in the ii-th test case into substrings that satisfy the conditions, and No otherwise.


Sample Input 1

5
4
abac
3
cac
2
ab
12
abababababab
5
edcba

Sample Output 1

Yes
No
Yes
Yes
No

For the first test case, you can divide SS into a, ba, c.

For the second test case, there is no way to divide SS into substrings so that they are strictly increasing in lexicographical order.