s = 0
unseen = 0
seen(v) = bittest(s, v)
see(v) = s = bitor(s, 2^v); while (seen(unseen), unseen++)

other(p) = {
	see(p);
	for (v=unseen, oo,
		if (!seen(v) && issquare(b=bitand(p, v)),
			return (v);
		);
	);
}

b=0; for (n=0, 2^13, v=if (n==0, 0, other(v)); print (n " " sqrtint(b)))

quit