#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long inf = 1e18;
long long power(long long a, long long b, long long mod) {
  long long c = 1;
  a = a % mod;
  while (b > 0) {
    if (b % 2) c *= a;
    c %= mod;
    b /= 2;
    a *= a;
    a %= mod;
  }
  return c;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long a[n];
    vector<pair<long long, long long> > p, v;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      v.push_back({a[i], i});
    }
    sort(v.begin(), v.end());
    long long cost = 0;
    if (n == 2 || n > m) {
      cout << -1 << "\n";
      continue;
    }
    for (long long i = 0; i < n; i++) {
      if (i == n - 1) {
        cost += a[i] + a[0];
        p.push_back({i + 1, 1LL});
        continue;
      }
      cost += a[i] + a[i + 1];
      p.push_back({i + 1, i + 2});
    }
    for (long long i = n; i < m; i++) {
      cost += v[0].first + v[1].first;
      p.push_back({v[0].second + 1, v[1].second + 1});
    }
    cout << cost << "\n";
    for (long long i = 0; i < m; i++)
      cout << p[i].first << " " << p[i].second << "\n";
  }
}
