#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n + 2];
    bool fool = true;
    if (n == 2) fool = false;
    if (m < n) fool = false;
    int first, second, fp = -1, sp = -1;
    first = second = INT_MAX;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", a + i);
      if (a[i] <= first) {
        sp = fp;
        second = first;
        first = a[i];
        fp = i;
      }
      if (a[i] < second && a[i] != first) {
        second = a[i];
        sp = i;
      }
    }
    for (int i = 0; i < n; i++) {
      sum += (a[i] + a[(i + 1) % n]);
    }
    sum = sum + (second + first) * (m - n);
    if (second == INT_MAX) {
      second = first;
      sp = fp + 1;
    }
    sp++;
    fp++;
    if (fool == false) {
      printf("-1\n");
      continue;
    }
    printf("%lld\n", sum);
    for (int i = 1; i < n; 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", fp, sp);
    }
  }
}
