#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5, INF = 0x3f3f3f3f;
template <typename T>
void read(T &x) {
  x = 0;
  long long f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  x *= f;
}
int t, n, m, m1, m2, n1, n2;
int a[N];
int main() {
  read(t);
  while (t--) {
    int s = 0;
    m1 = INF, m2 = INF;
    read(n), read(m);
    for (int i = 1; i <= n; ++i) {
      read(a[i]);
      if (a[i] < m1) {
        m1 = a[i];
        n1 = i;
      }
      s += a[i];
    }
    for (int i = 1; i <= n; ++i) {
      if (a[i] < m2 && i != n1) {
        m2 = a[i];
        n2 = i;
      }
    }
    if (m < n || n == 2) {
      puts("-1");
      continue;
    }
    int tmp = m - n;
    printf("%d\n", 2 * s + tmp * (m1 + m2));
    for (int i = 1; i < n; ++i) {
      printf("%d %d\n", i, i + 1);
    }
    printf("%d %d\n", n, 1);
    for (int i = 1; i <= tmp; ++i) {
      printf("%d %d\n", n1, n2);
    }
  }
  return 0;
}
