#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 3e4 + 25, oo = 1e9 + 7;
const long long OO = 1e18 + 25;
int t, n, m, x, ans;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &x);
      ans += x;
    }
    if (m < n || n == 2)
      printf("-1\n");
    else {
      printf("%d\n", ans * 2);
      for (int i = 1; i < n; i++) printf("%d %d\n", i, i + 1);
      printf("%d 1\n", n);
    }
  }
  return 0;
}
