def d(s,i): if i>6:print s for c in"123456":c in s or c==`i`or d(s+c,i+1) d("",1)