#include <bits/stdc++.h>
using namespace std;
long long n, m, d, mn, p = 1, a[310101], mx1, asdaf, k, asdasd, ans1, ans2, ans,
                       suf[310001], pref[310001], mx, b[310001];
map<long long, long long> us1;
long long us[1001][1001];
deque<long long> v, v1;
deque<pair<long long, long long> > q;
long long dx[4] = {0, 0, 1, -1};
long long dy[4] = {1, -1, 0, 0};
int main() {
  long long t24 = 1;
  cin >> t24;
  for (long long qwe = 1; qwe <= t24; qwe++) {
    long long sum = 0, f = 1, q1 = -1, r = 1e9, l = 0, q = 1e9, kol = 0,
              kol1 = 0;
    mx = -1e15, mx1 = -1e15, mn = 1e15, ans = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      long long a;
      cin >> a;
      sum += 2 * a;
    }
    if (n == m && n != 2) {
      cout << sum << endl;
      for (int i = 1; i <= n; i++)
        cout << i << " " << (i + 1 - 1) % n + 1 << endl;
    } else
      cout << "-1\n";
  }
  return 0;
}
