#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
int main() {
  int t;
  cin >> t;
  for (int cases = 0; cases < t; cases++) {
    int n, m;
    vector<pi> a(10010);
    cin >> n >> m;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int in;
      cin >> in;
      a[i] = make_pair(in, i + 1);
      ans += 2 * in;
    }
    if (n == 2 || m < n) {
      cout << -1 << endl;
      continue;
    }
    sort(a.begin(), a.begin() + n);
    ans += (m - n) * (a[0].first + a[1].first);
    cout << ans << endl;
    for (int i = 1; i < n; i++) {
      cout << i << " " << i + 1 << endl;
    }
    cout << n << " " << 1 << endl;
    for (int i = 0; i < m - n; i++) {
      cout << a[0].second << " " << a[1].second << endl;
    }
  }
}
