s = 0
unseen = 0
seen(v) = bit test(s, v)
see(v) = s = bit or(s, 2^v); while (seen(unseen), unseen++)

p = 0

other() = {
	for (v=unseen, oo,
		if (!seen(v),
			my (pv=bitxor(p,v));
			if (issquare(pv),
				p=pv;
				see(v);
				return (sqrtint(p));
			);
		);
	);
}

for (n=0, 2^13, print (n " " other()))

quit