#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long PO(long long a, long long n) {
  long long val = 1;
  for (long long i = 0; i < n; i++) val *= a;
  return val;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, long long> > v(n + 1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      cin >> v[i].first;
      v[i].second = i;
      ans += v[i].first;
    }
    ans *= 2;
    if (n == 2)
      cout << -1 << "\n";
    else {
      if (m < n)
        cout << -1 << "\n";
      else {
        sort(v.begin() + 1, v.end());
        long long sz = m - n;
        long long p1 = v[1].second;
        long long p2 = v[2].second;
        ans += sz * (v[1].first + v[2].first);
        cout << ans << "\n";
        for (long long i = 1; i <= n - 1; i++) {
          cout << i << " " << i + 1 << "\n";
        }
        cout << n << " " << 1 << "\n";
        for (long long i = 0; i < sz; i++) cout << p1 << " " << p2 << "\n";
      }
    }
  }
}
