#include #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); int a, b, c, d; int main() { scanf("%d %d %d %d", &a, &b, &c, &d); int xs[3] = {a - c, c, b - c}; dumpiii(xs[0], xs[1], xs[2]); int zero = xs[0] != 0 ? 0 : 1; int one = xs[2] != 0 ? 2 : 1; if( zero == one ) { puts("-1"); return 0; } for(int i = 0; i < 3; ++i) { if( xs[i] < 0 ) { puts("-1"); return 0; } } std::vector> res; int tops[3] = {-1, -1, -1}; tops[zero] = 0; tops[one] = 1; int id = 2; if( tops[1] == -1 and xs[1] != 0 ) { tops[1] = id; id += 1; } if( tops[1] != -1 ) { if( tops[0] != -1 ) { res.push_back(std::make_pair(tops[0], tops[1])); } if( tops[2] != -1 ) { res.push_back(std::make_pair(tops[2], tops[1])); } } for(int j = 0; j < 3; ++j) { for(int i = 0; i < xs[j] - (tops[j] == -1 ? 0 : 1); ++i) { res.push_back(std::make_pair(tops[j], id)); id += 1; } } int n = id; int m = res.size(); if( m > d ) { puts("-1"); return 0; } printf("%d %d\n", n, m); for(int i = 0; i < m; ++i) { printf("%d %d\n", res[i].first, res[i].second); } return 0; }