#include <bits/stdc++.h>
using namespace std;
struct node {
  int i;
  int num;
} a[1005];
bool cmp(node x, node y) { return x.num < y.num; }
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d %d", &n, &m);
    int i, j;
    int ans = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i].num);
      a[i].i = i;
      ans += a[i].num;
    }
    if (m < n || n <= 2) {
      printf("-1\n");
      continue;
    }
    ans *= 2;
    sort(a + 1, a + 1 + n, cmp);
    int num = a[1].num + a[2].num;
    ans += (m - n) * num;
    printf("%d\n", ans);
    for (i = 2; i <= n; i++) {
      printf("%d %d\n", i - 1, i);
    }
    printf("1 %d\n", n);
    for (i = 0; i < (m - n); i++) {
      if (a[1].i > a[2].i)
        printf("%d %d\n", a[2].i, a[1].i);
      else
        printf("%d %d\n", a[1].i, a[2].i);
    }
  }
  return 0;
}
