#include <bits/stdc++.h>
using namespace std;
int no_tests;
int no_people;
int no_chains;
int x;
bool sortbysec(const pair<int, int>& a, const pair<int, int>& b) {
  return (a.second < b.second);
}
int main() {
  cin >> no_tests;
  while (no_tests) {
    vector<pair<int, int>> weights_fridges;
    int minimum_cost = 0;
    cin >> no_people >> no_chains;
    for (int it = 1; it <= no_people; ++it) {
      cin >> x;
      weights_fridges.push_back(make_pair(it, x));
    }
    sort(weights_fridges.begin(), weights_fridges.end(), sortbysec);
    if (no_chains < no_people || no_people == 2) {
      cout << -1 << endl;
    } else {
      int aux = no_chains;
      while (aux) {
        for (vector<pair<int, int>>::iterator it = weights_fridges.begin();
             it != weights_fridges.end() - 1; ++it) {
          if (!aux) {
            break;
          }
          vector<pair<int, int>>::iterator jt = it + 1;
          minimum_cost = minimum_cost + (*it).second + (*jt).second;
          aux = aux - 1;
        }
        if (aux) {
          vector<pair<int, int>>::iterator it = weights_fridges.begin();
          vector<pair<int, int>>::iterator jt = weights_fridges.end() - 1;
          minimum_cost = minimum_cost + (*it).second + (*jt).second;
          aux = aux - 1;
        }
      }
      cout << minimum_cost << endl;
      while (no_chains) {
        for (vector<pair<int, int>>::iterator it = weights_fridges.begin();
             it != weights_fridges.end() - 1; ++it) {
          if (!no_chains) {
            break;
          }
          vector<pair<int, int>>::iterator jt = it + 1;
          cout << (*it).first << " " << (*jt).first << endl;
          no_chains = no_chains - 1;
        }
        if (no_chains) {
          vector<pair<int, int>>::iterator it = weights_fridges.begin();
          vector<pair<int, int>>::iterator jt = weights_fridges.end() - 1;
          cout << (*it).first << " " << (*jt).first << endl;
          no_chains = no_chains - 1;
        }
      }
    }
    no_tests = no_tests - 1;
  }
}
