#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int a[n];
    vector<pair<long long int, long long int> > v;
    for (long long int i = 0; i < n; i++) cin >> a[i];
    if (n <= 2) {
      cout << -1 << endl;
      continue;
    }
    if (m < n) {
      cout << -1 << endl;
      continue;
    }
    long long int ans = 0;
    for (long long int i = 0; i < n - 1; i++) {
      ans += (a[i] + a[i + 1]);
      v.push_back({i + 1, i + 2});
    }
    ans += (a[0] + a[n - 1]);
    v.push_back({1, n});
    m -= n;
    while (m--) {
      long long int mi = INFINITY, first, second;
      for (long long int i = 0; i < n; i++) {
        if (mi > a[i]) {
          first = i + 1;
          mi = a[i];
        }
      }
      long long int ma = INT_MAX;
      for (long long int i = 0; i < n; i++) {
        if (ma > a[i] && i + 1 != first) {
          ma = a[i];
          second = i + 1;
        }
      }
      ans += (ma + mi);
      v.push_back({first, second});
    }
    cout << ans << endl;
    for (long long int i = 0; i < v.size(); i++)
      cout << v[i].first << " " << v[i].second << endl;
  }
}
