#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, t, m, k;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld%lld", &n, &m);
    long long int sum = 0;
    for (long long int i = 0; i < n; ++i) {
      long long int wt;
      scanf("%lld", &wt);
      sum += wt;
    }
    if (m != n || n == 2)
      cout << -1 << endl;
    else {
      cout << sum * 2 << endl;
      for (long long int i = 1; i <= n - 1; ++i) {
        cout << i << " " << i + 1 << endl;
      }
      cout << n << " " << 1 << endl;
    }
  }
  return 0;
}
