Under construction

Still being built. Things may change

GC-Ratio

Time limit2sMemory limit128 MB

Summary
Find the contiguous segment of length at least L with the largest share of ones, breaking ties by shorter length then earlier start.
Level

Medium7 of 10

Topics
Binary search, Prefix sum
Solved
No attempts yet

Problem

A DNA sequence is made up of the letters A, C, G, and T. The GC-ratio of a DNA sequence is the number of C and G divided by the length of the sequence. Regions with a high GC-ratio are more likely to be the start of a gene, so the GC-ratio is an important measure.

Research often looks for the substring (a contiguous segment) with the largest GC-ratio inside a very long DNA sequence. Because short substrings with a high GC-ratio are usually meaningless, a lower bound LL on the length is fixed, and only substrings of length at least LL are considered.

If every A and T is replaced by 00 and every C and G by 11, the DNA sequence becomes a binary sequence of the same length. The average value of this binary sequence equals the GC-ratio of the original DNA sequence.

Index1234567891011121314151617
Value00101011011011010

For the binary sequence above, if the lower bound is 77, the substring with the maximum average is [7,14][7, 14] with average 6/86/8. If the lower bound is 55, the substring with the maximum average is [7,11][7, 11] with average 4/54/5.

Given a binary sequence and a length lower bound LL, write a program that finds the substring with the maximum average among all substrings of length at least LL. If several substrings share the maximum average, choose the one with the shortest length; if several of those exist, choose the one with the earliest starting position.

Input

The first line contains the number of test cases TT. Each test case consists of two lines. The first line contains the length of the binary sequence nn and the length lower bound LL (1≤n≤100,0001 \le n \le 100{,}000, 1≤L≤1,0001 \le L \le 1{,}000). The second line contains the binary sequence of length nn.

Output

For each test case, print the starting position and the ending position of the chosen substring on one line, separated by a space. Positions are counted from 11.

Examples1

  1. Example 1

    Input
    2
    17 5
    00101011011011010
    20 4
    11100111100111110000
    
    Expected output
    7 11
    6 9