Nasser's Sorted Substring#13083

Nasser's Sorted Substring

1 second
256 megabytes

Nasser will give you a string of lowercase English letters.

You are allowed to perform at most one operation:

Your task is to determine the longest sorted substring you can achieve after performing at most one change.

A sorted substring is a contiguous part of the string where each character is greater than or equal to the previous one (non-decreasing order).

Input

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

The first line of each test case contains an integer (1 \le n \le 2 \cdot 10^5) — the length of the string.

The second line of each test case contains a string of length , consisting of lowercase English letters ('a' to 'z').

It is guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^5.

Output

For each test case, print a single integer — the length of the longest sorted substring that can be achieved after performing at most one character change.

Examples

Example 1

Loading
Loading

Note

In the third test case, n=4, s=\texttt{``abca''}:

  • The string is not fully sorted since s[3]=\texttt{'c'} > s[4]=\texttt{'a'}.

  • We can change s[4]=\texttt{'a'} to : becomes , which is fully sorted. Length .

  • We can also change s[4]=\texttt{'a'} to : becomes , which is fully sorted. Length .

  • No single change can give a sorted substring of length greater than .

  • Answer: .

Scoring

  1. Subtask ( points) : (1 \le \sum n \le 1000)

  2. Subtask ( points) : The string consists of at most distinct characters.

  3. Subtask ( points) : No additional constraints.