Garland decorator is a profession which recently gained in importance, especially during Christmas time. Any kid can decorate a christmas tree, any parent can put gifts in sockets, and even anyone can start believing in Santa Claus, but hanging christmas garlands is a completely difflerent story. As you will learn, it is an extremely important, responsible and tough job. A garland consists of n pieces of equal length. Due to decorations like christmas balls attached to garlands, piece i has its own weight wi. The garland has to be attached to the ceiling in m spots, where the very beginning of the garland should be attached to spot 1 and its end to spot m. The garland should also be hooked to the remaining spots, which divides it into segments, each consisting of several consecutive pieces. There are, however, several rules that every respectable garland decorator should keep in mind. (i) Each segment should contain a positive even number of pieces. Due to this condition, we may divide a segment into two half-segments. (ii) To minimize the chance that a guest hits your precious garland with their head (and tears it into pieces), the garland cannot hang too low: each half-segment can contain at most d pieces. (iii) Finally, to keep the ceiling from falling on people heads, the decorator should minimize the weight of the heaviest half-segment. An example of an optimally hanging garland (consisting of twelve pieces in three segments) is presented below; weights of respective pieces are given in circles. Input The input contains several test cases. The first line of the input contains a positive integer Z ≤ 50, denoting the number of test cases. Then Z test cases follow, each conforming to the format described below. The description of each garland consists of two lines. The first line describing a particular garland contains three positive integers n, m, and d (1 ≤ n ≤ 40000, 2 ≤ m ≤ 10000, 1 ≤ d ≤ 10000) separated by single spaces and described above. The second line contains n positive integers w1, w2, . . . , wn (1 ≤ wi ≤ 10000), being the weights of the corresponding pieces. Output For each test case, your program has to write an output conforming to the format described below. For each garland, your program should output a single line containing one integer, being the weight of the heaviest half-segment in an optimal attachment of the garland. If it is not possible to hang the garland satisfying conditions (i) and (ii), then your program should output word ‘BAD’.
2/2 Sample Input 4 4 3 10 10 10 20 20 6 4 10 1 1 100 100 1 1 6 3 10 1 1 100 100 1 1 122 333 Sample Output 20 100 200 BAD