from itertools import* for x in permutations('012345'):print' '.join(x)