Chandan is back with his array to blow your mind. As usual Chandan has an array consisting of N integers .He allows you to perform 2 kinds of operation on his array.

Type 1 : Increment any integer of the array by 1.

Type 2 : Decrement any integer of the array by 1.

You can perform these operation as many times as you want on his array.

Each  operation of Type 1 costs 3 while each operation of Type 2 costs 5.

Now Chandan wants to have K equal elements in his array.So he asks you to tell him the minimum cost required in obtaining K equal elements in his array.

Input:

The first line contains T indicating test cases.Second line contains 2 integers N indicating the number of elements in his array and K.

Third line contains N space separated integers denoting Chandan array.

Output:

The minimum cost required to get K equal elements.

Constraints :

1 ≤ T ≤ 100

1 ≤ K ≤ N ≤100

1 ≤ A[i] ≤100

SAMPLE INPUT
1
5 3
9 4 9 7 4 

SAMPLE OUTPUT
6

Explanation

We can convert 7 to 9 to get three 9. The cost of this conversion will be 6.
t=int(raw_input())
n=[]
l=[]
for k in range(t):
	n.append(raw_input())
	l.append(raw_input())

def getmin(l):
	mn=-1
#	print l
	for i in l:
		cost=0
		for j in l:
			temp=i-j
			#print temp
			if(temp<0):
				temp=abs(temp)*5
			else:
				temp=abs(temp)*3
			cost+=temp
		#print cost
		if mn==-1 or mn>cost:
			mn=cost
	return mn
			

for k in range(t):
	arr = map(int,l[k].split())
	size,subsize = map(int,n[k].split())
	arr.sort()
	#print arr
	soln=[]
	for i in range(size-subsize+1):
		soln.append(getmin(arr[i:i+subsize]))
	#print soln
	print min(soln)
	del soln