#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int* arr = new int[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    if (n == 2 || n != m)
      cout << "-1\n";
    else {
      int ans = 0;
      for (int i = 0; i < n - 1; i++) ans += arr[i] + arr[i + 1];
      ans += arr[0] + arr[n - 1];
      cout << ans << '\n';
      cout << 1 << " " << n << '\n';
      for (int i = 1; i < n; i++) cout << i << " " << i + 1 << '\n';
    }
  }
  return 0;
}
