n,k=list(map(int,input().split()))

h=[int(eval(input()))for _ in range(n)]

h.sort()

a=9999999999

for i in range(n-k+1):a=min(a,h[i+k-1]-h[i])

print(a)
n,k=list(map(int,input().split()))

h=[int(eval(input()))for _ in range(n)]

h.sort(reverse=1)

print((min(h[i-k+1]-h[i] for i in range(k-1,n))))
n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h.sort()
a = 9999999999
for i in range(n - k + 1):
    a = min(a, h[i + k - 1] - h[i])
print(a)

n, k = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(n)]
h.sort(reverse=1)
print((min(h[i - k + 1] - h[i] for i in range(k - 1, n))))

-h.sort() -a = 9999999999 -for i in range(n - k + 1): -    a = min(a, h[i + k - 1] - h[i]) -print(a) +h.sort(reverse=1) +print((min(h[i - k + 1] - h[i] for i in range(k - 1, n))))