#include <bits/stdc++.h>
using namespace std;
const int MA = 1e5 + 5;
struct node {
  int val, si;
} a[MA];
bool cmp(const node& p, const node& q) { return p.val < q.val; }
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    scanf("%d%d", &n, &m);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i].val);
      a[i].si = i;
      ans += a[i].val;
    }
    if (m < n || n < 3) {
      printf("-1\n");
      continue;
    }
    sort(a + 1, a + n + 1, cmp);
    ans *= 2;
    ans += (m - n) * (a[2].val + a[1].val);
    printf("%d\n", ans);
    for (int i = 1; i <= n; ++i) {
      if (i != n)
        printf("%d %d\n", i, i + 1);
      else
        printf("%d 1\n", n);
    }
    for (int i = 1; i <= m - n; ++i) {
      printf("%d %d\n", a[1].si, a[2].si);
    }
  }
  return 0;
}
