#include <bits/stdc++.h>
using namespace std;
int n, q;
signed main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, m;
    cin >> n >> m;
    int a[n];
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      sum += a[j];
    }
    int min_ = 1 << 31 - 1;
    int min_index;
    for (int j = 0; j < n; j++) {
      int x = a[j] + a[(j + 1) % n];
      if (x < min_) min_ = x, min_index = j;
    }
    if (m < n or n == 2)
      cout << -1 << endl;
    else {
      cout << 2 * sum + (m - n) * min_ << endl;
      for (int j = 0; j < n; j++) {
        int l = j + 2;
        if (l > n) l -= n;
        if (j == min_index)
          for (int r = 0; r < m - n + 1; r++) {
            cout << j + 1 << " " << l << endl;
          }
        else {
          cout << j + 1 % n << " " << l << endl;
        }
      }
    }
  }
}
