Generalizations of de Bruijn Cycles and Gray Codes