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