#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
struct fridge {
  int w, id;
} f[maxn];
struct edge {
  int u, v;
} e[maxn];
bool cmp(fridge a, fridge b) { return a.w < b.w; }
int n, m, a[maxn], ans, fd[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      ans += a[i];
    }
    if (m < n || n == 2) {
      printf("-1\n");
      continue;
    }
    cout << ans * 2 << endl;
    for (int i = 1; i < n; i++) {
      printf("%d %d\n", i, i + 1);
    }
    printf("%d %d\n", n, 1);
  }
  return 0;
}
