#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, all = 0, tmp, t1 = INT_MAX, t2 = INT_MAX, aa, bb;
    cin >> n >> m;
    if (n > m or n == 2) {
      cout << -1 << endl;
      for (int i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
           i += 2 * ((0) < (n)) - 1)
        cin >> tmp;
    } else {
      for (int i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
           i += 2 * ((0) < (n)) - 1) {
        cin >> tmp;
        all += tmp;
        if (t1 > tmp) {
          t2 = t1;
          t1 = tmp;
          bb = aa;
          aa = i;
        } else if (t2 > tmp) {
          t2 = tmp;
          bb = i;
        }
      }
      cout << all * 2 + (t1 + t2) * (m - n) << endl;
      for (int i = (1) - ((1) > (n + 1)); i != (n + 1) - ((1) > (n + 1));
           i += 2 * ((1) < (n + 1)) - 1) {
        cout << i << ' ' << (i % n) + 1 << endl;
      }
      for (int i = (0) - ((0) > (m - n)); i != (m - n) - ((0) > (m - n));
           i += 2 * ((0) < (m - n)) - 1) {
        cout << aa + 1 << ' ' << bb + 1 << endl;
      }
    }
  }
}
