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