#include #include using namespace std; int a, b, c, d; bool is_swap = false; int main() { cin >> a >> b >> c >> d; if (a > b) { swap(a, b); is_swap = true; } if (c == 0) { if (a + b - 2 > d) { cout << -1 << endl; return 0; } cout << a + b << " " << a + b - 2 << endl; for (int i = 0; i < a - 1; i++) { cout << is_swap << " " << 2 + i << endl; } for (int i = 0; i < b - 1; i++) { cout << (!is_swap) << " " << a + 1 + i << endl; } return 0; } if ((a == b && b == c) || b - 1 + a - c > d) { cout << -1 << endl; return 0; } cout << b + a - c << " " << b - 1 + a - c << endl; if (a >= 2) cout << is_swap << " " << 2 << endl; for (int i = 0; i < a - 2; i++) { cout << 2 + i << " " << 3 + i << endl; } int prev_id = a - c + 1; if (prev_id == 1) prev_id = (is_swap); int id = ((b + a - c == a + 1) ? (!is_swap) : a + 1); for (int i = 0; i < b - c; i++) { cout << id << " " << prev_id << endl; prev_id = id; if (i + 2 == b - c) id = (!is_swap); else id++; } return 0; }