#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, m, n, a[100000], s, i;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    s = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      s += a[i];
    }
    if (n < 3 || m < n)
      cout << "-1" << endl;
    else {
      cout << 2 * s << endl;
      for (i = 1; i <= n; i++) {
        if (i == n)
          cout << i << " " << 1 << endl;
        else
          cout << i << " " << i + 1 << endl;
      }
    }
  }
}
