#include <bits/stdc++.h>
const int MAXN = 1e3 + 5;
using namespace std;
pair<int, int> a[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      cin >> a[i].first;
      a[i].second = i;
    }
    sort(a, a + n);
    int ans = 0;
    vector<pair<int, int> > ve;
    if (m < n || n == 2) {
      ans = -1;
    } else {
      for (int i = 0; i < n; i++) {
        ans += a[i - 1 == -1 ? n - 1 : i - 1].first + a[i].first;
        ve.push_back(make_pair(a[i - 1 == -1 ? n - 1 : i - 1].second + 1,
                               a[i].second + 1));
      }
      m -= n;
      while (m > 0) {
        ans += a[0].first + a[1].first;
        ve.push_back(make_pair(a[0].second, a[1].second + 1));
      }
    }
    cout << ans << endl;
    for (int i = 0; i < ve.size(); i++) {
      cout << ve[i].first << " " << ve[i].second << endl;
    }
  }
}
