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

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

print((min([_max - _min for _min, _max in zip(heights, heights[K - 1:])])))

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

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

print((min((_max - _min for _min, _max in zip(heights, heights[K - 1:])))))

N, K = list(map(int, input().split(" ")))
heights = sorted([int(eval(input())) for _ in range(N)])
print((min([_max - _min for _min, _max in zip(heights, heights[K - 1 :])])))

N, K = list(map(int, input().split(" ")))
heights = sorted([int(eval(input())) for _ in range(N)])
print((min((_max - _min for _min, _max in zip(heights, heights[K - 1 :])))))

-print((min([_max - _min for _min, _max in zip(heights, heights[K - 1 :])]))) +print((min((_max - _min for _min, _max in zip(heights, heights[K - 1 :])))))