#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1004;
int main() {
  int t;
  cin >> t;
  vector<pair<int, int> > vii;
  while (t--) {
    int n;
    cin >> n;
    int m;
    cin >> m;
    int a[MAXN], mi = INT_MAX;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
    }
    if (m < n || n == 2) {
      cout << -1 << endl;
    } else {
      int sum = 0;
      pair<int, int> p;
      for (int i = 0; i < n; i++) {
        int buil;
        if (i + 2 <= n) {
          vii.push_back({i + 1, i + 2});
          buil = a[i + 1] + a[i];
          sum += buil;
          if (mi > buil) {
            mi = buil;
            p = {i + 1, i};
          }
        } else {
          vii.push_back({n, 1});
          buil = a[n - 1] + a[0];
          sum += buil;
          if (mi > buil) {
            mi = buil;
            p = {1, n};
          }
        }
      }
      sum += (m - n) * mi;
      for (int d = 0; d < m - n; d++) {
        vii.push_back(p);
      }
      cout << sum << endl;
      for (int k = 0; k < vii.size(); k++) {
        pair<int, int> pp = vii[k];
        cout << pp.first;
        cout << " ";
        cout << pp.second << endl;
      }
      vii.clear();
    }
  }
  return 0;
}
