#include <bits/stdc++.h>
using namespace std;
vector<int> x, temp, h;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v, v1;
    int has[100007];
    int a[100007];
    memset(has, 0, sizeof(has));
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      v.push_back(make_pair(a[i], i));
    }
    if (n == 2) {
      cout << "-1\n";
      continue;
    }
    sort(v.begin(), v.end());
    int flag = 0, ans = 0, cpt = 0;
    for (int i = 0; i < n; i++) {
      int indx = v[i].second;
      int cost = v[i].first;
      if (i < n - 1) {
        v1.push_back(make_pair(indx, v[i + 1].second));
        ans += cost + v[i + 1].first;
        has[indx]++;
        has[v[i + 1].second]++;
        m -= 1;
        cpt += 1;
        if (m == 0) {
          flag = 1;
          break;
        }
      } else {
        v1.push_back(make_pair(indx, v[0].second));
        ans += cost + v[0].first;
        m -= 1;
        cpt += 1;
        has[indx]++;
        has[v[0].second]++;
        if (m == 0) {
          flag = 1;
          break;
        }
      }
    }
    if (flag) {
      int flg = 0;
      for (int i = 1; i <= n; i++) {
        if (has[i] < 2) {
          flg = 1;
          break;
        }
      }
      if (flg)
        cout << "-1\n";
      else {
        cout << ans << "\n";
        for (int i = 0; i < cpt; i++) {
          cout << v1[i].first << " " << v1[i].second << "\n";
        }
      }
    } else {
      while (m > 0) {
        v1.push_back(make_pair(v[0].second, v[1].second));
        ans += v[0].first + v[1].first;
        cpt += 1;
        m -= 1;
      }
      cout << ans << "\n";
      for (int i = 0; i < cpt; i++) {
        cout << v1[i].first << " " << v1[i].second << "\n";
      }
    }
  }
}
