#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const int inf2 = 1e18;
const int mod = 1000000007;
struct node {
  int i, num;
  bool operator<(const node &q) const { return num < q.num; }
} no[1010];
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++) {
      no[i].i = i;
      scanf("%d", &no[i].num);
      ans += no[i].num;
    }
    if (n == 2 || m < n) {
      printf("-1\n");
      continue;
    }
    sort(no + 1, no + n + 1);
    ans *= 2;
    ans += (m - n) * (no[1].num + no[2].num);
    printf("%d\n", ans);
    for (int i = 1; i < n; i++) {
      printf("%d %d\n", no[i].i, no[i + 1].i);
    }
    printf("%d %d\n", no[n].i, no[1].i);
    for (int i = n + 1; i <= m; i++) {
      printf("%d %d\n", no[1].i, no[2].i);
    }
  }
  return 0;
}
