row(n) = { my (r = [0], d, b = 1); while (n, if (n % 2, n -= d = 2 - (n%4); r = concat(r, [v + d*b | v <- r]); ); n /= 2; b *= 2; ); vecsort(r); } { seen = 0; m = -1; a = vector(5461); u = 1; print ("0 0"); for (n = 0, 2^14, r = - row(n); for (i = 1, #r, if (r[i] >= 0 && !bittest(seen, r[i]), seen += 2^r[i]; m++; if (r[i] && r[i] <= #a, a[r[i]] = m; while (a[u], print (u " " a[u]); if (u++ > #a, break (3); ); ); ); ); ); ); } quit