move(z) = {
	my (w=max(abs(real(z)), abs(imag(z))));
	if (imag(z)==-w, z+1,
		imag(z)==+w, z-1,
		real(z)==-w, z-I,
		             z+I
	);
}

z=0; for (n=0, 10000, print (n " " imag(z)); z=move(z))

quit