#include #include #include #include #include #include using namespace std; typedef long long LL; typedef vector VI; #define REP(i,n) for(int i=0, i##_len=(n); i inline void amin(T &x, const T &y) { if (y inline void amax(T &x, const T &y) { if (x void rprintf(const char *fmt, Iter begin, Iter end) { for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); } putchar('\n'); } LL tri(LL x) { return x * (x+1) / 2; } int T, B, F, C; int N; VI G[100111]; int main() { scanf("%d%d%d%d", &T, &B, &F, &C); N = T + 1; for (int left=0; left<=N-1; left++) { int right = N-1-left; if ((LL)left * right >= C && tri(left) + tri(right) >= B && tri(left-1) + tri(right-1) >= F) { // 0 // [1..left] // [left+1..N-1] // Tree REP (i, left) G[i].push_back(i+1); G[0].push_back(left+1); REP (i, right-1) G[left+1+i].push_back(left+2+i); // Back int cnt = 0; REP (i, left+1) REP (j, i) { if (cnt >= B) goto BREAK; G[i].push_back(j); cnt++; } REP (i, right+1) REP (j, i) { if (cnt >= B) goto BREAK; int a = i + left; int b = (j? j + left: 0); G[a].push_back(b); cnt++; } BREAK: // Forward cnt = 0; REP (i, left+1) REP (j, i-1) { if (cnt >= F) goto BREAK_F; G[j].push_back(i); cnt++; } REP (i, right+1) REP (j, i-1) { if (cnt >= F) goto BREAK_F; int a = i + left; int b = (j? j + left: 0); G[b].push_back(a); cnt++; } BREAK_F: // Cross cnt = 0; REP (i, left) REP (j, right) { if (cnt >= C) goto BREAK_C; int a = i + 1; int b = j + 1 + left; G[b].push_back(a); cnt++; } BREAK_C: eprintf("%d %d\n", left, right); printf("%d\n", N); REP (i, N) { printf("%d", (int) G[i].size()); REP (j, G[i].size()) printf(" %d", G[i][j]+1); putchar('\n'); } return 0; } } puts("-1"); return 0; }