#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const T& v) {
  cerr << v << ' ';
}
template <typename T1, typename... T2>
void print(const T1& first, const T2&... rest) {
  print(first);
  print(rest...);
}
typedef priority_queue<pair<int, int>, vector<pair<int, int> >,
                       greater<pair<int, int> > >
    pq;
int setbit(int N, int pos) { return N = N | (1 << pos); }
int resetbit(int N, int pos) { return N = N & ~(1 << pos); }
bool checkbit(int N, int pos) { return (bool)(N & (1 << pos)); }
int nextN(int N) { return N + (N & (-N)); }
int parentN(int N) { return N - (N & (-N)); }
template <typename T>
T extGcd(T a, T b, T& x, T& y) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  T x1, y1, gcd = extGcd(b % a, a, &x1, &y1);
  x = y1 - (b / a) * x1, y = x1;
  return gcd;
}
template <typename T>
T bigMod(T a, T p, T m) {
  if (p == 1) return a;
  T x = bigMod(a, p / 2, m) % m;
  x = (x * x) % m;
  return (p & 1) ? (x * a) % m : x;
}
template <typename T>
T modMul(T a, T b, T m) {
  return ((a % m) * (b % m)) % m;
}
template <typename T>
T modAdd(T a, T b, T m) {
  return ((a % m) + (b % m)) % m;
}
template <typename T>
T modSub(T a, T b, T m) {
  return (a - b + m) % m;
}
template <typename T>
T modInverse(T a, T m) {
  return bigMod(a, m - 2, m);
}
struct e {
  int u, v, c;
};
bool cmp(const e a, const e b) { return a.c < b.c; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, t, m;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int mm = m;
    vector<pair<int, int> > a(n);
    for (int i = 0; i <= n - 1; ++i) {
      cin >> a[i].first;
      a[i].second = i;
    }
    if (m < n || n <= 2) {
      cout << -1 << endl;
      continue;
    }
    sort(a.begin(), a.end());
    vector<e> ans;
    int cst = 0;
    for (int i = 0; i < n; i++) {
      e x;
      if (i == n - 1) {
        x.u = i, x.v = 0;
        x.c = a[i].first + a[0].first;
      } else {
        x.u = i, x.v = i + 1;
        x.c = a[i].first + a[i + 1].first;
      }
      ans.push_back(x);
      cst += x.c;
      m--;
    }
    sort(ans.begin(), ans.end(), cmp);
    vector<pair<int, int> > an;
    int i = (int)ans.size() - 1;
    for (; i >= 2 && m > 0; i--) {
      e x = ans[i];
      int w = a[x.u].first + a[0].first + a[x.v].first + a[1].first;
      if (w < ans[i].c) {
        x.u = ans[i].u, x.v = 0;
        an.push_back({x.u, x.v});
        x.u = ans[i].v, x.v = 1;
        an.push_back({x.u, x.v});
        m--;
        cst -= ans[i].c;
        cst += w;
      } else
        an.push_back({x.u, x.v});
    }
    for (; i >= 0; i--) an.push_back({ans[i].u, ans[i].v});
    for (int i = 1; i <= m; ++i) {
      an.push_back({0, 1});
      cst += a[0].first + a[1].first;
    }
    cout << cst << endl;
    for (int i = 0; i <= mm - 1; ++i)
      cout << a[an[i].first].second + 1 << " " << a[an[i].second].second + 1
           << endl;
  }
  return 0;
}
