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