#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n, m, a, s = 0;
    cin >> n >> m;
    for (int64_t i = 0; i < n; i++) cin >> a, s += 2 * a;
    if (m == n && n > 2) {
      cout << s << "\n";
      for (int64_t i = 1; i < n; i++) cout << i << " " << i + 1 << "\n";
      cout << n << " 1\n";
    } else
      cout << "-1\n";
  }
  return 0;
}
