#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[1010];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m;
    scanf("%d %d", &n, &m);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &p[i].first);
      p[i].second = i + 1;
      sum += p[i].first;
    }
    if (m < n || n == 2)
      printf("-1\n");
    else {
      sort(p, p + n);
      printf("%d\n", 2 * sum + (m - n) * (p[0].first + p[1].first));
      for (int i = 1; i <= n; i++) printf("%d %d\n", i, (i % n) + 1);
      for (int i = 0; i < m - n; i++)
        printf("%d %d\n", p[0].second, p[1].second);
    }
  }
}
