#include <bits/stdc++.h>
using namespace std;
const int N = 1003;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> used(N, vector<bool>(N, 0));
  vector<pair<int, int>> a;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    int w;
    cin >> w;
    b[i] = w;
    a.push_back({w, i});
  }
  if (n != m || n == 2) {
    cout << -1 << "\n";
    return;
  }
  sort(a.begin(), a.end());
  vector<pair<int, int>> ans;
  vector<int> loop;
  long long Q = 0;
  int i = 0;
  while (loop.size() != n) {
    loop.push_back(a[i].second);
    if (loop.size() >= n) break;
    loop.push_back(a[n - i - 1].second);
    ++i;
  }
  for (int i = 0; i < n; ++i) {
    Q += b[loop[i]] + b[loop[(i + 1) % n]];
    ans.push_back({loop[i], loop[(i + 1) % n]});
  }
  cout << Q << "\n";
  for (auto e : ans) {
    cout << e.first + 1 << " " << e.second + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
