#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
const ll INF = 1e18;
void solve() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, int>> input = vector<pair<ll, int>>(n);
  for (int i = 0; i < n; ++i) {
    cin >> input[i].first;
    input[i].second = i + 1;
  }
  if (n > m || n == 2)
    cout << -1 << '\n';
  else {
    sort(input.begin(), input.end());
    ll sum = 0;
    for (auto a : input) sum += 2 * a.first;
    m -= n;
    sum += m * (input[0].first + input[1].first);
    cout << sum << '\n';
    for (int i = 0; i < n; ++i) {
      cout << i + 1 << " " << (i + 1) % n + 1 << '\n';
    }
    for (int i = 0; i < m; ++i) {
      cout << input[0].second << " " << input[1].second << '\n';
    }
  }
}
int main() {
  int t = 1;
  cin >> t;
  for (int i = 0; i < t; ++i) solve();
}
