#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9, INF = 1e16;
signed main() {
  long long n;
  cin >> n;
  while (n--) {
    long long t, m;
    cin >> t >> m;
    vector<pair<long long, long long> > kavo(t);
    for (long long i = 0; i < t; ++i) {
      cin >> kavo[i].first;
      kavo[i].second = i;
    }
    sort(kavo.rbegin(), kavo.rend());
    vector<pair<long long, long long> > ans;
    if (t == 2 || m < t) {
      cout << -1 << endl;
      continue;
    }
    long long sum = 0;
    for (long long i = 0; i < t - 1; ++i) {
      ans.push_back({kavo[i].second, kavo[i + 1].second});
      sum += kavo[i].first + kavo[i + 1].first;
    }
    ans.push_back({kavo[0].second, kavo[t - 1].second});
    sum += kavo[0].first + kavo[t - 1].first;
    m -= t;
    while (m > 0) {
      ans.push_back({kavo[t - 1].second, kavo[t - 2].second});
      sum += kavo[t - 1].first + kavo[t - 2].first;
      --m;
    }
    cout << sum << endl;
    for (long long i = 0; i < ans.size(); ++i)
      cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << endl;
  }
}
