#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc, n, m;
  cin >> tc;
  while (tc--) {
    cin >> n >> m;
    int cost = 0;
    int arr[n];
    vector<pair<int, int> > ans;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    if (m < n || n <= 2)
      cout << -1 << "\n";
    else {
      int i = 1, k = 0;
      while (i < n && k < m) {
        cost += (arr[i] + arr[i - 1]);
        if (i == n - 1) {
          cost += (arr[i] + arr[0]);
          i = 0;
          k++;
          ans.push_back({n, 1});
        }
        i++;
        k++;
        ans.push_back({i + 1, i});
      }
      cout << cost << "\n";
      for (int i = 0; i < ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
    }
  }
}
