#include <bits/stdc++.h>
using namespace std;
bool canConstructTree(int n, int d, int l) {
// Basic validation
if (l < 2 || l > n - (d - 1)) return false; // Invalid number of leaves
if (d >= n) return false; // Diameter must be less than the number of nodes
// Special cases
if (n == 2) return (d == 1 && l == 2);
if (d == 1) return (l == n-1);
if (d == 2) return (l >= 2 && l <= n-1);
// For general case
return (l >= 2 && l <= n - (d-1));
}
void constructTree(int n, int d, int l) {
if (!canConstructTree(n, d, l)) {
cout << -1 << "\n";
return;
}
// Case 1: Diameter 1 (Star-shaped tree)
if (d == 1) {
for (int i = 2; i <= n; i++) {
cout << "1 " << i << "\n";
}
return;
}
// Case 2: Diameter 2
if (d == 2) {
int center = 1;
int nonLeafNode = 2;
cout << center << " " << nonLeafNode << "\n";
// Add leaves to both nodes
int currentNode = 3;
int remainingLeaves = l;
// First attach to center
while (currentNode <= n && remainingLeaves > 1) {
cout << center << " " << currentNode << "\n";
currentNode++;
remainingLeaves--;
}
// Then to non-leaf node
while (currentNode <= n) {
cout << nonLeafNode << " " << currentNode << "\n";
currentNode++;
}
return;
}
// General case (d > 2)
// First create a spine of length d-1
for (int i = 1; i < d; i++) {
cout << i << " " << i + 1 << "\n";
}
int currentNode = d + 1;
int remainingLeaves = l - 1; // Reserve one leaf for later
// Add remaining leaves to spine nodes (except last node)
for (int i = 1; i < d && currentNode < n && remainingLeaves > 0; i++) {
// Add leaves to each spine node
if (i == 1 || i == d-1) { // For first and second-last nodes
while (currentNode < n && remainingLeaves > 0) {
cout << i << " " << currentNode << "\n";
currentNode++;
remainingLeaves--;
if (i == 1 && remainingLeaves == 0) break; // Ensure we save one leaf
}
}
}
// Add any remaining internal nodes
for (int i = 2; i < d-1 && currentNode < n; i++) {
cout << i << " " << currentNode << "\n";
currentNode++;
}
// Finally add the last node to complete the diameter
if (currentNode <= n) {
cout << d-1 << " " << currentNode << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n, d, l;
cin >> n >> d >> l;
constructTree(n, d, l);
}
return 0;
}