CF2048C.Kevin and Binary Strings

传统题 时间 2000 ms 内存 256 MiB 6 尝试 10 已通过 3 标签

Kevin and Binary Strings

Kevin discovered a binary string ss that starts with 1 in the river at Moonlit River Park and handed it over to you. Your task is to select two non-empty substrings^{\text{∗}} of ss (which can be overlapped) to maximize the XOR value of these two substrings.

The XOR of two binary strings aa and bb is defined as the result of the \oplus operation applied to the two numbers obtained by interpreting aa and bb as binary numbers, with the leftmost bit representing the highest value. Here, \oplus denotes the bitwise XOR operation.

The strings you choose may have leading zeros.

^{\text{∗}}A string aa is a substring of a string bb if aa can be obtained from bb by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1031 \le t \le 10^3).

The only line of each test case contains a binary string ss that starts with 1 (1s50001\le\lvert s\rvert\le 5000).

It is guaranteed that the sum of s\lvert s\rvert over all test cases doesn't exceed 50005000.

Output

For each test case, output four integers l1,r1,l2,r2l_1, r_1, l_2, r_2 (1l1r1s1 \le l_1 \le r_1 \le |s|, 1l2r2s1 \le l_2 \le r_2 \le |s|) — in the case the two substrings you selected are sl1sl1+1sr1s_{l_1} s_{l_1 + 1} \ldots s_{r_1} and sl2sl2+1sr2s_{l_2} s_{l_2 + 1} \ldots s_{r_2}.

If there are multiple solutions, print any of them.

Note

In the first test case, we can choose s2=1s_2=\texttt{1} and s1s2s3=111s_1 s_2 s_3=\texttt{111}, and 1}\oplus\texttt{111}=\texttt{110. It can be proven that it is impossible to obtain a larger result. Additionally, l1=3l_1=3, r1=3r_1=3, l2=1l_2=1, r2=3r_2=3 is also a valid solution.

In the second test case, s1s2s3=100s_1 s_2 s_3=\texttt{100}, s1s2s3s4=1000s_1 s_2 s_3 s_4=\texttt{1000}, the result is 100}\oplus\texttt{1000}=\texttt{1100, which is the maximum.

Samples

5
111
1000
10111
11101
1100010001101
2 2 1 3
1 3 1 4
1 5 1 4
3 4 1 5
1 13 1 11

在线编程 IDE

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