#define _CRT_SECURE_NO_WARNINGS #pragma comment(linker, "/stack:16777216") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i) #define FILL(A,value) memset(A,value,sizeof(A)) #define ALL(V) V.begin(), V.end() #define SZ(V) (int)V.size() #define PB push_back #define MP make_pair #define Pi 3.14159265358979 typedef long long Int; typedef unsigned long long UInt; typedef vector VI; typedef pair PII; const int INF = 1000000000; const int MAX = 100007; const int MAX2 = 1000000; const int MAXD = 20; const int BASE = 1000000007; const int MOD = 1000000007; vector G[MAX]; vector cross, fw , bc; VI path; int t , b , f , c; int F , B; void dfs(int v) { path.push_back(v); FOR(i,0,(int)SZ(path) - 2) { if (F == 0) break; fw.push_back(MP(path[i] , v)); -- F; } FOR(i,0,(int)SZ(path) - 1) { if (B == 0) break; bc.push_back(MP(v , path[i])); -- B; } FOR(i,0,SZ(G[v])) { int to = G[v][i]; dfs(to); } path.pop_back(); } int main() { //freopen("in.txt" , "r" , stdin); cin >> t >> b >> f >> c; F = f; B = b; if (t + b + f + c == 0) { cout << 1 << endl; cout << 0 << endl; return 0; } int n = t + 1; int maxC = 1LL * (n - 1) * (n - 2); if (c > maxC) { cout << -1 << endl; return 0; } int cnt = 0; int cc = c; FOR(i,1,n + 1) { if (cc >= i) { ++ cnt; cc -= i; } } int c2 = cnt + 2 + (cc != 0); int cur = 1; int last = 0; FOR(i,0,n - c2) { G[last].push_back(last + 1); ++ last; ++ cur; } int v = last + 1; int del = -1; FOR(i,0,cnt + 1) { G[last].push_back(cur); FOR(j,v,cur) { if (j == del) continue; cross.push_back(MP(cur , j)); } ++cur; if (i == cc && cc != 0) { G[cur - 1].push_back(cur); last = cur - 1; del = cur - 1; FOR(j,v,cur) { if (j == del) continue; cross.push_back(MP(cur , j)); } ++cur; } } dfs(0); if (SZ(cross) < c || SZ(fw) < f || SZ(bc) < b) { cout << -1 << endl; return 0; } FOR(i,0,c) { G[cross[i].first].push_back(cross[i].second); } FOR(i,0,b) { G[bc[i].first].push_back(bc[i].second); } FOR(i,0,f) { G[fw[i].first].push_back(fw[i].second); } cout << n << endl; FOR(i,0,n) { printf("%d" , SZ(G[i])); FOR(j,0,SZ(G[i])) { printf(" %d" , G[i][j] + 1); } printf("\n"); } return 0; }