#include <bits/stdc++.h>
double a = 2 * acos(0.0);
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.second < p2.second)
    return true;
  else if (p1.second == p2.second and p1.first < p1.first)
    return true;
  else
    return false;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> ara;
    vector<pair<int, int> > vc;
    int i;
    for (i = 0; i < n; i++) {
      int abul;
      cin >> abul;
      ara.push_back(abul);
      vc.push_back({i, abul});
    }
    ara.push_back(ara[0]);
    sort(vc.begin(), vc.end(), cmp);
    if (m < n or n < 3) {
      cout << "-1" << endl;
      continue;
    }
    vector<pair<int, int> > otpt;
    long long cn = 0;
    for (i = 0; i < n; i++) {
      cn += ara[i] + ara[i + 1];
      if (i < n - 1)
        otpt.push_back({i + 1, i + 2});
      else if (i == n - 1)
        otpt.push_back({i + 1, 1});
    }
    for (i = n; i < m; i++) {
      cn += vc[0].second + vc[1].second;
      otpt.push_back({vc[0].first + 1, vc[1].first + 1});
    }
    cout << cn << endl;
    for (i = 0; i < m; i++) {
      cout << otpt[i].first << " " << otpt[i].second << endl;
    }
  }
  return 0;
}
