N, K = list(map(int, input().split()))

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

h.sort()

diff = max(h)

for i in range(0, len(h)-K+1):

  if diff > h[i+K-1]-h[i]:

    diff = h[i+K-1]-h[i]

print(diff)
n,k=list(map(int,input().split()));h=sorted([int(eval(input())) for _ in range(n)])

print((min([h[i+k-1]-h[i] for i in range(n-k+1)])))
N, K = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(N)]
h.sort()
diff = max(h)
for i in range(0, len(h) - K + 1):
    if diff > h[i + K - 1] - h[i]:
        diff = h[i + K - 1] - h[i]
print(diff)

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

-N, K = list(map(int, input().split())) -h = [int(eval(input())) for _ in range(N)] -h.sort() -diff = max(h) -for i in range(0, len(h) - K + 1): -    if diff > h[i + K - 1] - h[i]: -        diff = h[i + K - 1] - h[i] -print(diff) +n, k = list(map(int, input().split())) +h = sorted([int(eval(input())) for _ in range(n)]) +print((min([h[i + k - 1] - h[i] for i in range(n - k + 1)])))