#include <bits/stdc++.h>
using namespace std;
using par = pair<long long, long long>;
par as[5000];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long T;
  cin >> T;
  for (long long I = 0; I < T; ++I) {
    long long n, m;
    cin >> n >> m;
    long long s2 = 0;
    for (long long i = 0; i < n; ++i) {
      long long a;
      cin >> a;
      s2 += 2 * a;
      as[i] = {a, i + 1};
    }
    sort(as, as + n);
    if (m < n || n == 2) {
      cout << -1 << '\n';
      continue;
    }
    cout << s2 + (as[0].first + as[1].first) * (m - n) << '\n';
    for (long long i = 1; i < n; ++i) cout << i << ' ' << i + 1 << '\n';
    cout << n << ' ' << 1 << '\n';
    for (long long i = n; i < m; ++i) {
      cout << as[0].second << ' ' << as[1].second << '\n';
    }
  }
  return 0;
}
