#include #include using namespace std; int main() { int A, B, C, D; cin >> A >> B >> C >> D; // Calculate total number of villages int N = A + B - C; if (N < 2) { cout << -1 << endl; return 0; } // Check if C exceeds min(A, B) if (C > min(A, B)) { cout << -1 << endl; return 0; } // Calculate minimum number of edges needed int min_edges = (A - C) + (B - C) + (C > 0 ? C + 1 : 0); if (min_edges > D) { cout << -1 << endl; return 0; } cout << N << " " << min_edges << endl; int cnt = 1; // Start counting new villages from 2 // Villages only reachable from 0 for (int i = 0; i < A - C; ++i) { cout << 0 << " " << ++cnt << endl; } // Villages only reachable from 1 for (int i = 0; i < B - C; ++i) { cout << 1 << " " << ++cnt << endl; } // Common villages reachable from both 0 and 1 if (C > 0) { int rt = ++cnt; cout << 0 << " " << rt << endl; cout << 1 << " " << rt << endl; for (int i = 1; i < C; ++i) { cout << rt << " " << ++cnt << endl; } } return 0; }