#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1000;
const long long INF64 = 1e18 + 1000;
const int N = 2 * 1e5 + 1000;
const int MOD = 1e9 + 7;
const double EPS = 1E-9;
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2) return a * binpow(a, b - 1);
  long long t = binpow(a, b / 2);
  return t * t;
}
vector<int> p;
void spr(int x) { cout << setprecision(x) << fixed; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < int(n); ++i) cin >> a[i];
    if (n == 2 || n > m) {
      cout << -1 << endl;
      continue;
    }
    cout << 2 * accumulate(a.begin(), a.end(), 0) << endl;
    cout << n << ' ' << 1 << endl;
    for (int i = 0; i < int(n - 1); ++i) {
      cout << i + 1 << ' ' << i + 2 << endl;
    }
  }
}
