#include using namespace std; #define F first #define S second #define pi M_PI #define R cin>> #define Z class #define ll long long #define ln cout<<'\n' #define in(a) insert(a) #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define all(c) (c).begin(),(c).end() #define iter(c) __typeof((c).begin()) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define rep(i,n) REP(i,0,n) #define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++) templatevoid pr(A a){cout<void pr(A a,B b){cout<void pr(A a,B b,C c){cout<void pr(A a,B b,C c,D d){cout<void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<=0&&x=0&&y P; void Main() { int a[4]; rep(i,4) R a[i]; { int x=a[0]-a[2],y=a[1]-a[2]; vector v,v2,v3; vector

ans; v.pb(0);v2.pb(1); int k=2; if(x&&y) { rep(i,x-1) v.pb(k++); rep(i,y-1) v2.pb(k++); rep(i,a[2]) v3.pb(k++); rep(i,v.size()-1) ans.pb(P(v[i],v[i+1])); rep(i,v2.size()-1) ans.pb(P(v2[i],v2[i+1])); if(v3.size()) { ans.pb(P(v[v.size()-1],v3[0])); ans.pb(P(v2[v2.size()-1],v3[0])); } rep(i,v3.size()-1) ans.pb(P(v3[i],v3[i+1])); } else if(x) { rep(i,a[0]-2) v.pb(k++); v.pb(1); rep(i,v.size()-1) ans.pb(P(v[i],v[i+1])); ans.pb(P(1,v[v.size()-a[2]])); } else if(y) { rep(i,a[1]-2) v2.pb(k++); v2.pb(0); rep(i,v2.size()-1) ans.pb(P(v2[i],v2[i+1])); ans.pb(P(0,v2[v2.size()-a[2]])); } else { if(a[2]<2) { pr(-1); return; } k=0; rep(i,a[2]-1) { ans.pb(P(k,k+1)); k++; } ans.pb(P(k,0)); } if(ans.size()<=a[3]) { int n=2; rep(i,ans.size()) n=max(n,max(ans[i].F,ans[i].S)+1); pr(n,ans.size()); rep(i,ans.size()) pr(ans[i].F,ans[i].S); return; } } { int x=a[0]-a[2],y=a[1]-a[2]; vector v,v2,v3; vector

ans; v.pb(0);v2.pb(1); int k=2; if(x&&y) { rep(i,x-1) v.pb(k++); rep(i,y-1) v2.pb(k++); } else if(x) { rep(i,x-1) v.pb(k++); v.pb(1); a[2]--; } else if(y) { rep(i,y-1) v2.pb(k++); v2.pb(0); a[2]--; } else { if(a[2]<2) { pr(-1); return; } ans.pb(P(0,1)); ans.pb(P(1,0)); a[2]-=2; if(a[2]) v.pb(k++); } rep(i,a[2]) v3.pb(k++); rep(i,v.size()-1) ans.pb(P(v[i],v[i+1])); rep(i,v2.size()-1) ans.pb(P(v2[i],v2[i+1])); if(v3.size()) { if(x) ans.pb(P(v[v.size()-1],v3[0])); if(y) ans.pb(P(v2[v2.size()-1],v3[0])); } rep(i,v3.size()-1) ans.pb(P(v3[i],v3[i+1])); if(ans.size()<=a[3]) { int n=2; rep(i,ans.size()) n=max(n,max(ans[i].F,ans[i].S)+1); pr(n,ans.size()); rep(i,ans.size()) pr(ans[i].F,ans[i].S); return; } } pr(-1); } int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}