#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int FMOD = 998244353;
const double eps = 1e-9;
void solve() {
  int n, m;
  cin >> n >> m;
  int v, sm = 0;
  for (auto i = (1); (1) > 0 ? i <= (n) : i >= (n); i += (1)) {
    cin >> v;
    sm += v;
  }
  if (m < n || n < 3)
    cout << -1 << "\n";
  else {
    cout << sm * 2 << "\n";
    for (auto i = (0); (1) > 0 ? i <= (n - 1) : i >= (n - 1); i += (1))
      cout << i + 1 << " " << (i + 1) % n + 1 << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int ntc = 1;
  cin >> ntc;
  for (auto tc = (1); (1) > 0 ? tc <= (ntc) : tc >= (ntc); tc += (1)) {
    solve();
  }
  return 0;
}
