#include <bits/stdc++.h>
using namespace std;
int t, n, m;
struct fridge {
  int id, w;
};
bool operator<(const fridge& f1, const fridge& f2) {
  if (f1.w != f2.w) return (f1.w < f2.w);
  return (f1.id < f2.id);
}
vector<fridge> f;
void solve() {
  cin >> n >> m;
  f.resize(n);
  for (int i = 1; i <= n; ++i) {
    f[i - 1].id = i;
    cin >> f[i - 1].w;
  }
  sort(f.begin(), f.end());
  if (n == 2 || m < n) {
    cout << -1 << endl;
    return;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) ans += 2 * f[i].w;
  ans += (m - n) * (f[0].w + f[1].w);
  cout << ans << endl;
  for (int i = 0; i + 1 < n; ++i) {
    cout << f[i].id << " " << f[i + 1].id << endl;
    m--;
  }
  cout << f[n - 1].id << " " << f[0].id << endl;
  m--;
  while (m--) {
    cout << f[0].id << " " << f[1].id << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) solve();
  return 0;
}
