#include <bits/stdc++.h>
using namespace std;
// Speed
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// Typedefs
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'
void solve() {
int n, m;
cin >> n >> m;
vector<pair<int, int>> a(n);
int sum_all = 0;
for(int i = 0; i < n; i++) {
cin >> a[i].ff;
a[i].ss = i + 1; // Store 1-based index
sum_all += a[i].ff;
}
// Sort by value.
// a[0] is smallest, a[n-1] is largest.
sort(all(a));
// CASE 1: m = 0 (Kill everyone)
if (m == 0) {
// We need the sum of all n-1 elves to be enough to kill the nth elf.
int king_health = a[n-1].ff;
int damage_pool = sum_all - king_health;
if (damage_pool < king_health) {
cout << -1 << endl;
return;
}
cout << n - 1 << endl;
// Everyone attacks the King
// Smallest to largest attack the King
for(int i = 0; i < n - 1; i++) {
cout << a[i].ss << " " << a[n-1].ss << endl;
}
return;
}
// CASE 2: m > 0 (Keep m survivors)
// We need m survivors to have "already attacked".
// This requires m victims.
// Total needed: m (survivors) + m (victims) = 2m.
if (n < 2 * m) {
cout << -1 << endl;
return;
}
// Groups indices (in sorted array):
// Trash: 0 ... n - 2m - 1
// Targets: n - 2m ... n - m - 1 (Count: m)
// Survivors: n - m ... n - 1 (Count: m)
vector<pair<int, int>> moves;
// 1. Process Trash
// Chain them: 0->1, 1->2 ... LastTrash -> FirstTarget
int first_target_idx = n - 2 * m;
for (int i = 0; i < first_target_idx; i++) {
// If it's the very last trash item, it attacks the first target
if (i == first_target_idx - 1) {
moves.pb({a[i].ss, a[first_target_idx].ss});
} else {
// Otherwise trash attacks next trash
moves.pb({a[i].ss, a[i+1].ss});
}
}
// 2. Survivors attack Targets
// We pair S_i with T_i.
// Survivor index: n - m + i
// Target index: n - 2m + i
for (int i = 0; i < m; i++) {
int surv_idx = n - m + i;
int targ_idx = n - 2 * m + i;
moves.pb({a[surv_idx].ss, a[targ_idx].ss});
}
cout << sz(moves) << endl;
for(auto p : moves) {
cout << p.ff << " " << p.ss << endl;
}
}
int32_t main() {
fast_io;
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}