#include <bits/stdc++.h>
using namespace std;
int vis[10000];
vector<int> c[10000];
void dfs(int a) {
  vis[a] = 1;
  for (int i = 0; i < c[a].size(); i++) {
    int child = c[a][i];
    if (!vis[child]) {
      dfs(child);
      cout << a << " " << child << '\n';
    }
  }
}
int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; i++) {
    int n, m, a;
    vector<int> v;
    cin >> n >> m;
    for (int x = 0; x <= m; x++) c[x].clear();
    for (int i = 0; i <= n; i++) vis[i] = 0;
    for (int j = 0; j < n; j++) {
      cin >> a;
      v.push_back(a);
    }
    if (n > m || n == 2)
      cout << -1 << '\n';
    else {
      int a, b, s = 0;
      for (int x = 1; x < m; x++) {
        c[x].push_back(x + 1);
        c[x + 1].push_back(x);
      }
      for (int x = 1; x < m; x++) s = s + v[x - 1] + v[x];
      cout << s + v[0] + v[m - 1] << '\n';
      dfs(1);
      cout << n << " " << 1 << '\n';
    }
  }
}
