#include <bits/stdc++.h>
using namespace std;
class abc {
 public:
  long long int x, y;
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tests;
  cin >> tests;
  for (long long int gg = 0; gg < tests; gg++) {
    long long int n, m;
    cin >> n >> m;
    vector<long long int> arr(n);
    long long int sum = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> arr[i];
      sum += arr[i];
    }
    vector<long long int> x1(arr);
    sort(arr.begin(), arr.end());
    if (m < n || n <= 2) {
      cout << "-1\n";
      continue;
    }
    m -= n;
    sum *= 2;
    sum += (arr[0] + arr[1]) * m;
    cout << sum << "\n";
    for (long long int i = 0; i < n - 1; i++) {
      cout << i + 1 << " " << i + 2 << "\n";
    }
    cout << n << " " << 1 << "\n";
    long long int y1 = 0, y2 = 0;
    for (long long int i = 0; i < n; i++) {
      if (x1[i] == arr[0]) {
        y1 = i + 1;
        break;
      }
    }
    for (long long int i = n - 1; i >= 0; i--) {
      if (x1[i] == arr[1]) {
        y2 = i + 1;
        break;
      }
    }
    for (long long int i = 0; i < m; i++) {
      cout << y1 << " " << y2 << "\n";
    }
  }
}
