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

H = [int(eval(input())) for i in range(n)]

H.sort(reverse=True)

ans = 10 ** 9



for i in range(n-k+1):

    h = H[i] - H[i+k-1]

    ans = min(ans, h)

    

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

A = [int(eval(input())) for i in range(n)]

A.sort(reverse=True)

B = []



for i in range(n-k+1):

    diff = A[i] - A[i+k-1]

    B.append(diff)

    

print((min(B)))
n, k = list(map(int, input().split()))
H = [int(eval(input())) for i in range(n)]
H.sort(reverse=True)
ans = 10**9
for i in range(n - k + 1):
    h = H[i] - H[i + k - 1]
    ans = min(ans, h)
print(ans)

n, k = list(map(int, input().split()))
A = [int(eval(input())) for i in range(n)]
A.sort(reverse=True)
B = []
for i in range(n - k + 1):
    diff = A[i] - A[i + k - 1]
    B.append(diff)
print((min(B)))

-H = [int(eval(input())) for i in range(n)] -H.sort(reverse=True) -ans = 10**9 +A = [int(eval(input())) for i in range(n)] +A.sort(reverse=True) +B = [] -    h = H[i] - H[i + k - 1] -    ans = min(ans, h) -print(ans) +    diff = A[i] - A[i + k - 1] +    B.append(diff) +print((min(B)))