Python: Change generation of bitorus so it works for 3x3.