#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
inline int read() {
  register int s = 0, w = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + (ch ^ 48);
    ch = getchar();
  }
  return s * w;
}
int a[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, sum = 0, m1 = INF, m2 = INF;
    cin >> n >> k;
    int u, v;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      sum += a[i];
      if (m1 > a[i]) {
        u = i;
        m1 = a[i];
      }
    }
    for (int i = 1; i <= n; i++) {
      if (m2 > a[i] && i != u) {
        v = i;
        m2 = a[i];
      }
    }
    int res = k - n;
    sum *= 2;
    sum = sum + res * (a[v] + a[u]);
    if (k < n || n == 2) {
      cout << -1 << endl;
      continue;
    }
    cout << sum << endl;
    for (int i = 1; i <= n; i++) {
      if (i == n) {
        printf("%d %d\n", 1, n);
      } else {
        printf("%d %d\n", i, i + 1);
      }
    }
    for (int i = 0; i < res; i++) {
      printf("%d %d\n", u, v);
    }
  }
  return 0;
}
