#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m, i, in, sum = 0;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
      cin >> in;
      sum += in;
    }
    if (m < n or n < 3) {
      cout << -1 << endl;
      continue;
    }
    cout << sum + sum << endl;
    for (i = 1; i < m; i++) {
      if (i == 1)
        cout << "1 2" << endl << "1 3" << endl;
      else if (i == m - 1)
        cout << i << ' ' << n << endl;
      else
        cout << i << ' ' << i + 2 << endl;
    }
  }
}
