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

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

ans = float('inf')

for i in range(N-K+1):

    ans = min(h[i+K-1] - h[i],ans) 

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

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

h = sorted(h)

ans = float('inf')

for i in range(N-K+1):

    ans = min(h[i+K-1] - h[i], ans)

print(ans)
N, K = list(map(int, input().split()))
h = sorted([int(eval(input())) for _ in range(N)])
ans = float("inf")
for i in range(N - K + 1):
    ans = min(h[i + K - 1] - h[i], ans)
print(ans)

N, K = list(map(int, input().split()))
h = [int(eval(input())) for _ in range(N)]
h = sorted(h)
ans = float("inf")
for i in range(N - K + 1):
    ans = min(h[i + K - 1] - h[i], ans)
print(ans)

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