#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int soma = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      soma += 2 * a[i];
    }
    if (m < n or n == 2) {
      cout << -1 << endl;
      continue;
    }
    cout << soma << endl;
    for (int i = 1; i <= n; i++) {
      if (i == n)
        cout << n << " 1\n";
      else
        cout << i << " " << i + 1 << endl;
    }
  }
  return 0;
}
