#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a;
    cin >> n >> m;
    deque<pair<int, int> > x, y;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      x.push_back({a, i});
    }
    y = x;
    sort(x.begin(), x.end());
    if (m < n or n == 2) {
      cout << -1 << endl;
      continue;
    }
    vector<pair<int, int> > ans;
    long long int sum = 0;
    sum += x[0].first + x[1].first;
    ans.push_back({x[0].second, x[1].second});
    pair<int, int> one = x[0];
    pair<int, int> two = x[1];
    x.pop_front();
    x.pop_front();
    m -= 1;
    int flag1 = 0;
    int flag2 = 0;
    while ((x.size() - 1) < (m - 2)) {
      flag1 = 1;
      pair<int, int> z = x.back();
      x.pop_back();
      ans.push_back({z.second, one.second});
      ans.push_back({z.second, two.second});
      sum += one.first + z.first;
      sum += two.first + z.first;
      m -= 2;
    }
    pair<int, int> last = one;
    while (!(x.empty())) {
      flag2 = 1;
      pair<int, int> cur = x.front();
      x.pop_front();
      ans.push_back({last.second, cur.second});
      sum += last.first + cur.first;
      last = cur;
      m--;
    }
    pair<int, int> cur;
    if (flag1 == 1) {
      cur = one;
    } else {
      cur = two;
    }
    if (cur != last) {
      ans.push_back({last.second, cur.second});
      sum += last.first + cur.first;
      last = cur;
      m--;
    }
    while (m > 0) {
      ans.push_back({one.second, two.second});
      sum += (one.first + two.first);
      m--;
    }
    cout << sum << endl;
    for (auto i : ans) {
      cout << i.first << " " << i.second << endl;
    }
  }
}
