#include <bits/stdc++.h>
using namespace std;
struct node {
  int id, x;
  bool friend operator<(node c, node d) { return c.x < d.x; }
} a[2000], t[3000];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, m, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i].x, a[i].id = i;
    if (n == 2 || m < n) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; ++i) ans += a[i].x * 2;
    sort(a + 1, a + 1 + n);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      t[++cnt].id = i;
      t[cnt].x = i % n + 1;
    }
    m -= n;
    while (m--) {
      ans += a[2].x + a[1].x;
      t[++cnt].id = a[1].id;
      t[cnt].x = a[2].id;
    }
    cout << ans << endl;
    for (int i = 1; i <= cnt; ++i) cout << t[i].id << ' ' << t[i].x << endl;
  }
}
