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