#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);
for(int i = 0; i < n; i++) {
cin >> a[i].ff;
a[i].ss = i + 1; // Store 1-based index
}
// Sort by attack value (small to large)
sort(all(a));
// Case 1: We want 0 survivors
if (m == 0) {
int sum_others = 0;
for(int i = 0; i < n - 1; i++) sum_others += a[i].ff;
// If the sum of all smaller elves is enough to kill the king
if (sum_others >= a[n-1].ff) {
cout << n - 1 << endl;
// Everyone attacks the king
for(int i = 0; i < n - 1; i++) {
cout << a[i].ss << " " << a[n-1].ss << endl;
}
} else {
cout << -1 << endl;
}
return;
}
// Case 2: We want m survivors
// We try to save the 'm' largest elves and sacrifice the 'n-m' smallest.
vector<pair<int, int>> moves;
// We use the largest available survivor as the current "tank"
int target_idx = n - 1;
int current_dmg = 0;
// Iterate through attackers from Largest to Smallest (Greedy)
// Attackers are indices 0 to n-m-1
for(int i = n - m - 1; i >= 0; i--) {
// Check if current tank is full
// We need: current_dmg + attacker_val < target_val
// (Must be STRICTLY less so the target survives with at least 1 HP)
while (target_idx >= n - m && current_dmg + a[i].ff >= a[target_idx].ff) {
target_idx--; // Move to the next strongest survivor
current_dmg = 0; // Reset damage for new tank
}
// If we ran out of survivors to take the hits
if (target_idx < n - m) {
cout << -1 << endl;
return;
}
// Assign attacker to current target
moves.pb({a[i].ss, a[target_idx].ss});
current_dmg += a[i].ff;
}
// Output valid sequence
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;
}