#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int m, n, t, ans;
pair<int, int> a[N];
vector<pair<int, int>> v;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    ans = 0;
    v.clear();
    for (int i = 1; i <= n; i++) scanf("%d", &a[i].first), a[i].second = i;
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n; i++) {
      v.push_back(make_pair(a[i].second, a[i + 1].second));
      ans += a[i].first + a[i + 1].first;
    }
    v.push_back(make_pair(a[n].second, a[1].second));
    ans += a[n].first + a[1].first;
    if (v.size() > m || n == 2) {
      puts("-1");
      continue;
    }
    for (int i = v.size() + 1; i <= m; i++) {
      v.push_back(make_pair(a[1].second, a[2].second));
      ans += a[1].first + a[2].first;
    }
    printf("%d\n", ans);
    for (int i = 0; i < v.size(); i++)
      printf("%d %d\n", v[i].first, v[i].second);
  }
}
