#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int c = 0, a, b, j, i;
    cin >> a >> b;
    int ar[a], sum = 0;
    for (i = 0; i < a; i++) {
      cin >> ar[i];
      sum = sum + ar[i];
    }
    if (a == b && a != 2) {
      cout << 2 * sum << "\n";
      for (i = 1; i <= a; i++) {
        j = i + 1;
        if (j > a) j = 1;
        cout << i << " " << j << "\n";
      }
    } else
      cout << "-1"
           << "\n";
  }
}
