#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int n, m, t;
struct Node {
  int id, v;
} a[maxn];
bool comp(Node A, Node B) { return A.v < B.v; }
int main() {
  cin >> t;
  while (t--) {
    scanf("%d%d", &n, &m);
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i].v);
      a[i].id = i;
      sum += a[i].v;
    }
    if (n == 2 || m < n) {
      puts("-1");
      continue;
    } else {
      sort(a + 1, a + 1 + n, comp);
      printf("%lld\n", (long long)(m - n) * (a[1].v + a[2].v) + sum * 2ll);
      printf("%d %d\n", 1, n);
      for (int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
      for (int i = 0; i < m - n; i++) printf("%d %d\n", a[1].id, a[2].id);
    }
  }
  return 0;
}
