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