s = 0 seen(v) = bittest(s, v) see(v) = s = bitor(s, 2^v) a = vector(8192, n, -1) u = 0 T = vector(1911) n = 0 m = -1 emit(t) = { if (n++ <= #T, T[n] = t; ); for (k = 1, #t, if (!seen(t[k]), see(t[k]); a[1+t[k]] = m++; ); ); while (a[1+u]>=0, print (u " " a[1+u]); if (u++ == #a, quit; ); ); } { emit([0, 1]); for (k = 1, #T, my (t = T[k]); if (#t > 1, emit(2*t[2..#t]); ); emit(concat( [2*t[1]+0, 2*t[1]+1], [2*v+1 | v <- t[2..#t]] )); ); } quit