#include #define int long long #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() bool st; using namespace std; templateistream&operator>>(istream&I,vector&v){for(auto&i:v)I>>i;return I;} templateostream&operator<<(ostream&O,vector v){for(auto i:v)O<> a >> b >> c >> d; bool impossible = false; vector > e; if (a == c and b == c) { if (c == 1) impossible = true; repeat (i,c) e.emplace_back(i, (i+1)%c); } else { int A = 1000000; int B = 2000000; int C = 3000000; map tr; if (c == 0) { for(int i=0;i compress; compress[A] = 0; compress[B] = 1; auto name = [&](int & i) { if (tr.count(i)) i = tr[i]; if (not compress.count(i)) { int size = compress.size(); compress[i] = size; } i = compress[i]; }; for (auto & it : e) { name(it.first); name(it.second); } } if (impossible or e.size() > d) { cout << -1 << endl; } else { cout << a+b-c << ' ' << e.size() << endl; for (auto it : e) cout << it.first << ' ' << it.second << endl; } } } bool ed; signed main(){ chrono::steady_clock::time_point St=chrono::steady_clock::now(); read_all(); chrono::steady_clock::time_point ST=chrono::steady_clock::now(); int t=1; //cin>>t; while(t--)AC::solve(); chrono::steady_clock::time_point ED=chrono::steady_clock::now(); cerr<(ED-St).count()<<" \tms\n"<<"Real Time : "<(ED-ST).count()<<" \tms\n"<<" : "<(ED-ST).count()<<" \t?s\n\n"<<"Total Memory : "<