#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int total, n, m, get_num;
  cin >> total;
  while (total--) {
    cin >> n >> m;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> get_num;
      ans += get_num;
    }
    if (n == 2 || m < n) {
      cout << -1 << endl;
    } else {
      ans *= 2;
      cout << ans << endl;
      for (int i = 1; i <= n; i++) {
        int j = (i + 1 > n ? 1 : i + 1);
        cout << i << " " << j << endl;
      }
    }
  }
  return 0;
}
