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