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