#include <bits/stdc++.h>
using namespace std;
void solve1() {}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long sum = 0;
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    int ca = a, cb = b;
    int arr[a];
    for (int i = 0; i < a; i++) {
      scanf("%d", &arr[i]);
    }
    if (b < a || a == 2) {
      cout << -1 << endl;
      continue;
    }
    sort(arr, arr + a);
    int pos = 0;
    bool o = 0;
    vector<map<int, int>> v;
    while (true) {
      set<pair<int, int>> res;
      for (int i = 0; i < a; i++) {
        int pre = i - 1, next = i + 1;
        if (i == 0) pre = a - 1;
        if (i == a - 1) next = 0;
        pair<int, int> p;
        p.first = i + 1;
        p.second = next + 1;
        if (p.second < p.first) swap(p.first, p.second);
        int tes = res.size();
        res.insert(p);
        if (res.size() > tes) sum += arr[p.first - 1] + arr[p.second - 1];
        pair<int, int> p2;
        p2.first = i + 1;
        p2.second = pre + 1;
        if (p2.second < p2.first) swap(p2.first, p2.second);
        tes = res.size();
        res.insert(p2);
        if (res.size() > tes) sum += arr[p2.first - 1] + arr[p2.second - 1];
      }
      break;
    }
    cout << sum << endl;
    set<pair<int, int>> res;
    for (int i = 0; i < a; i++) {
      int pre = i - 1, next = i + 1;
      if (i == 0) pre = a - 1;
      if (i == a - 1) next = 0;
      pair<int, int> p;
      p.first = i + 1;
      p.second = next + 1;
      if (p.second < p.first) swap(p.first, p.second);
      int tes = res.size();
      res.insert(p);
      if (res.size() > tes) cout << p.first << " " << p.second << endl;
      pair<int, int> p2;
      p2.first = i + 1;
      p2.second = pre + 1;
      if (p2.second < p2.first) swap(p2.first, p2.second);
      tes = res.size();
      res.insert(p2);
      if (res.size() > tes) cout << p2.first << " " << p2.second << endl;
    }
    cout << endl;
  }
  return 0;
}
