#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
struct node {
  int a;
  int x;
} s[N];
bool cmp(node h, node j) { return h.a < j.a; }
int main() {
  int t;
  scanf("%d", &t);
  for (int Case = 1; Case <= t; Case++) {
    int n, m;
    scanf("%d%d", &n, &m);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &s[i].a);
      s[i].x = i + 1;
      sum += s[i].a;
    }
    if (n > m || n == 2)
      printf("-1\n");
    else {
      sort(s, s + n, cmp);
      int p = s[0].a + s[1].a;
      sum *= 2;
      sum += (m - n) * p;
      printf("%lld\n", sum);
      for (int i = 1; i <= n - 1; i++) printf("%d %d\n", i, i + 1);
      printf("1 %d\n", n);
      for (int i = 0; i < (m - n); i++) printf("%d %d\n", s[0].x, s[1].x);
    }
  }
}
