#include <bits/stdc++.h>
using namespace std;
bool comp(long long i, long long j) { return (i < j); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long kt[1000], bb, cc, dd, i, j, maxx, a0, rrr, minn, x, ans_l, ans_r,
      min_sum, min_pos, sum1, sum2, sum3, sum4, sum5, y;
  long long h, a1, aa, k, n, l, r, t, ch, zz = 0, kl, odn = 1, m, m1, m2, m0,
                                          m3, m4, xl, xr, yl, yr;
  vector<long long> a;
  queue<int> q;
  string s, s1;
  char c;
  l = 0;
  h = 0;
  ch = 0;
  bb = 0;
  x = 0;
  aa = 0;
  a0 = 0;
  zz = 20000000000;
  k = 1;
  r = 4;
  t = -1;
  j = 0;
  zz = 0;
  y = 0;
  cin >> r;
  for (bb = 1; bb <= r; bb++) {
    cin >> n >> m;
    a.clear();
    for (i = 1; i <= n; i++) {
      cin >> zz;
      a.push_back(zz);
    }
    if ((m < n) or (n == 2)) {
      cout << "-1" << endl;
    } else {
      sort(a.begin(), a.end(), comp);
      sum1 = 0;
      for (i = 0; i < n; i++) sum1 += 2 * a[i];
      sum1 += (m - n) * (a[0] + a[1]);
      cout << sum1 << endl;
      cout << 1 << " " << n << endl;
      for (i = 0; i < n - 1; i++) cout << i + 1 << " " << i + 2 << endl;
      for (i = n + 1; i <= m; i++) cout << 1 << " " << 2 << endl;
    }
  }
  return 0;
}
