#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, eachWeight;
    cin >> n >> m;
    vector<pair<int, int> > weights;
    for (int i = 0; i < n; i++) {
      cin >> eachWeight;
      weights.push_back(make_pair(eachWeight, i + 1));
    }
    if (m < n || n == 2) {
      cout << -1 << endl;
      continue;
    }
    sort(weights.begin(), weights.end());
    long long int ans = 0;
    for (int i = 0; i < n - 1; i++) {
      ans += weights[i].first + weights[i + 1].first;
    }
    ans += weights[n - 1].first + weights[0].first;
    ans += (m - n) * (weights[0].first + weights[1].first);
    cout << ans << endl;
    for (int i = 0; i < n - 1; i++)
      cout << weights[i].second << " " << weights[i + 1].second << endl;
    cout << weights[0].second << " " << weights[n - 1].second << endl;
    for (int i = 0; i < m - n; i++)
      cout << weights[0].second << " " << weights[1].second << endl;
  }
  return 0;
}
