#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
bool prime[N + 5];
int vis[11111];
int main() {
  int tc = 1;
  cin >> tc;
  while (tc--) {
    int n;
    int m;
    cin >> n >> m;
    int ara[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> ara[i];
    }
    if (m < n || n == 2) {
      cout << "-1" << endl;
      continue;
    } else {
      int sum = 0;
      for (int i = 0; i < n - 1; i++) {
        sum += ara[i];
        sum += ara[i + 1];
      }
      sum += ara[n - 1];
      sum += ara[0];
      cout << sum << endl;
      for (int i = 1; i < n; i++) {
        cout << i << " " << i + 1 << endl;
      }
      cout << 1 << " " << n << endl;
    }
  }
}
