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