explore(n, rem) = { my (b=1-(n%2), m=n, e=1); for (i=1, #rem, m = 2*m + b; if (rem[i], e = 0; explore(m, vector(#rem, k, rem[k]-(k==i))); ); ); if (e, v[u++] = n; ); } { n = 0; for (m=1, 4, v = vector( (m*(m+1)/2)! / prod(k=1, m, k!) ); u = 0; explore(0, vector(m, k, k)); v = Set(v); for (i=1, #v, my (r=[], rem=v[i]); while (rem, r = concat(valuation(rem+(rem%2),2), r); rem \= 2^r[1]; ); for (j=1, #r, print (n++ " " r[j]); ); ); ); } quit