#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long MOD = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tl;
  cin >> tl;
  while (tl--) {
    long long n, m;
    cin >> n >> m;
    long long sum = 0;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    if (m < n) {
      cout << -1 << "\n";
    } else if (n == m && n == 2) {
      cout << -1 << "\n";
    } else {
      cout << 2 * sum << "\n";
      for (long long i = 1; i < n - 1; i++) {
        cout << i << " " << i + 1;
        cout << "\n";
      }
      cout << n - 1 << " " << n << "\n";
      cout << n << " " << 1 << "\n";
    }
  }
}
