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