Under construction

Still being built. Things may change

Hills And Valleys

Time limit2sMemory limit512 MB

Summary
Given a sequence of digits, find the interval to reverse so that the longest non-decreasing subsequence is as long as possible, and report that length with the interval.
Level

Hard8 of 10

Topics
Dynamic programming, String, Prefix sum
Solved
No attempts yet

Problem

Tauren has an integer sequence AA of length nn (1-based). He wants you to invert an interval [l,r][l, r] (1≤l≤r≤n1 \le l \le r \le n) of AA, that is, replace Al,Al+1,…,ArA_l, A_{l+1}, \ldots, A_r with Ar,Ar−1,…,AlA_r, A_{r-1}, \ldots, A_l, so that the length of the longest non-decreasing subsequence of AA is as large as possible. Find that maximal length and any interval whose inversion achieves it.

A non-decreasing subsequence of AA with length mm is Ax1,Ax2,…,AxmA_{x_1}, A_{x_2}, \ldots, A_{x_m} with 1≤x1<x2<…<xm≤n1 \le x_1 < x_2 < \ldots < x_m \le n and Ax1≤Ax2≤…≤AxmA_{x_1} \le A_{x_2} \le \ldots \le A_{x_m}.

Input

The first line contains one integer TT, the number of test cases. Each test case is given as follows. The first line contains one integer nn. The second line contains nn integers A1,A2,…,AnA_1, A_2, \ldots, A_n written without spaces.

Constraints: 1≤T≤1001 \le T \le 100, 1≤n≤1051 \le n \le 10^5, 0≤Ai≤90 \le A_i \le 9 for i=1,2,…,ni = 1, 2, \ldots, n. The sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

Output

For each test case, print three integers mm, ll, and rr separated by spaces on one line, where mm is the maximal length and [l,r][l, r] is the interval to invert.

Hint

In the first example, 864852302 becomes 032584682 after inverting [1,8][1, 8], and one of its longest non-decreasing subsequences is 03588. In the second example, 203258468 becomes 023258468 after inverting [1,2][1, 2], and one of its longest non-decreasing subsequences is 023588.

Examples1

  1. Example 1

    Input
    2
    9
    864852302
    9
    203258468
    
    Expected output
    5 1 8
    6 1 2