Alarmist

Time limit1sMemory limit128 MB

Summary
Given n samples and a window size w, compute the floor of each window average and report the difference between the largest and smallest average.
Level

Easy3 of 10

Topics
Sliding window, Array, Implementation
Solved
No attempts yet

Problem

As an end-of-the-world alarmist, you are always looking for new data to support your doomsday theories. A common form of data is a series of scalar samples taken over time — for example, the outdoor temperature recorded once per second for a whole day, or the height of the tide measured once per minute for a month. Given such a sampling, you want to check whether the gap between the largest sample and the smallest sample is large, so that you can shout that the world has changed dramatically and is about to end.

The trouble is that such data sets often contain erroneous samples whose values are far too large or far too small, caused by transient failures in the measuring equipment. To make your claims more believable, you smooth out these bad values by computing a moving average.

Given a series of nn samples s1,s2,…,sns_1, s_2, \ldots, s_n and a window size ww with w≤nw \le n, the moving average consists of n−w+1n - w + 1 values. The first value is the average of the first ww samples s1,s2,…,sws_1, s_2, \ldots, s_w. The second value is the average of the same window shifted one step forward, i.e. the average of s2,s3,…,sw+1s_2, s_3, \ldots, s_{w+1}, and so on. For simplicity, round each value of the moving average down to the nearest integer that is less than or equal to it (the floor).

For each data set, report the difference between the maximum and the minimum value of its moving average.

Input

The first line contains the number KK of data sets. The KK data sets follow, each in the form below.

The first line of a data set contains two integers nn and ww: the number of samples and the window size, with 1≤n≤1001 \le n \le 100 and 1≤w≤n1 \le w \le n. The next line contains nn non-negative integers, the samples; each sample is at most 10001000.

Output

For each data set, output a line Data Set x:, where xx is the number of the data set (starting from 1). On the next line, output the absolute difference between the maximum and the minimum value of the moving average. Follow each data set with a blank line.

Examples3

  1. Example 1

    Input
    2
    4 2
    2 9 1 0
    5 3
    100 110 5 105 105
    
    Expected output
    Data Set 1:
    5
    
    Data Set 2:
    2
    
  2. Example 2

    Input
    1
    5 1
    0 1000 500 250 750
    
    Expected output
    Data Set 1:
    1000
    
  3. Example 3

    Input
    1
    3 2
    1 2 4
    
    Expected output
    Data Set 1:
    2