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