#include <bits/stdc++.h>
using namespace std;
long long t, n, m, sum;
pair<long long, long long> a[1010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    sum = 0;
    for (long long i = 0; i < n; i++)
      cin >> a[i].first, a[i].second = i + 1, sum += a[i].first;
    if (m < n || n == 2) {
      cout << "-1\n";
      continue;
    }
    cout << sum + sum << "\n";
    for (long long i = 1; i < n; i++) cout << i << " " << i + 1 << endl;
    cout << n << " 1\n";
  }
  return 0;
}
