main=readLn>>=mapM_(putStrLn.unwords.map show).f f n=g n where g 0=[[]];g m=[i:j|i<-[0..n-1],j<-g$m-1,all(i/=)$zip[1..]j>>=h];h(p,q)=[q,q-p,q+p]