#include <bits/stdc++.h>
using namespace std;
int l[5000009], r[5000009];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, i, j, k, ans = 0;
    scanf("%d %d", &n, &m);
    vector<pair<int, int> > arr(n);
    for (i = 0; i < n; i++) {
      cin >> arr[i].first;
      arr[i].second = i + 1;
      ans += (arr[i].first + arr[i].first);
    }
    if (m >= n && n > 2) {
      sort(arr.begin(), arr.end());
      int kk = arr[0].first + arr[1].first;
      kk *= (m - n);
      ans += kk;
      printf("%d\n", ans);
      for (i = 1; i <= n; i++) {
        if (i == n) {
          printf("1 %d\n", n);
        } else {
          printf("%d %d\n", i, i + 1);
        }
      }
      for (i = n + 1; i <= m; i++) {
        printf("%d %d\n", arr[0].second, arr[1].second);
      }
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
