#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long int N = 100005;
const long long int mod = 119 << 23 | 1;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int pow(long long int a, long long int b, long long int c) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % c;
    b = b >> 1;
    a = (a * a) % c;
  }
  return res;
}
long long int t;
long long int n, m;
long long int a[N];
void solve() {
  cin >> n >> m;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    ans = ans + a[i] * 2;
  }
  sort(a, a + n);
  if (m < n or n < 3) {
    cout << -1 << '\n';
    return;
  }
  cout << ans << '\n';
  for (long long int i = 1; i <= n; i++) {
    cout << i << " " << (i % n + 1) << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
