for _ in range(int(input())):
n,m=map(int,input().split())
l=list(map(int,input().split()))
if n<3 or m<n:
print(-1)
else:
i,i1=-1,float('inf')
s=0
for x in range(n):
if l[x]<i1:
i1=l[x]
i=x
s+=l[x]
j,j1=-1,float('inf')
for x in range(n):
if x!=i and l[x]<j1:
j1=l[x]
j=x
print((2*s)+((m-n)*(i1+j1)))
for x in range(n-1):
print(x+1,x+2)
print(n,1)
for x in range(m-n):
print(i+1,j+1)
1278B - A and B | 1353D - Constructing the Array |
1269C - Long Beautiful Integer | 1076A - Minimizing the String |
913C - Party Lemonade | 1313A - Fast Food Restaurant |
681A - A Good Contest | 1585F - Non-equal Neighbours |
747A - Display Size | 285A - Slightly Decreasing Permutations |
515C - Drazil and Factorial | 1151E - Number of Components |
1151F - Sonya and Informatics | 556A - Case of the Zeros and Ones |
867A - Between the Offices | 1569A - Balanced Substring |
260A - Adding Digits | 1698C - 3SUM Closure |
1029B - Creating the Contest | 1421A - XORwice |
1029A - Many Equal Substrings | 1675D - Vertical Paths |
1271C - Shawarma Tent | 805A - Fake NP |
1163A - Eating Soup | 787A - The Monster |
807A - Is it rated | 1096A - Find Divisible |
1430C - Numbers on Whiteboard | 1697B - Promo |