import Data.Set (fromList, toList, (\\))

set  = Data.Set.fromList
list = Data.Set.toList 
symbols = set [0..9]

perms = [ [a,b,c,d,e,f,g,h,i,j] |
          a <- list symbols,
          b <- list $ symbols \\ set [a],
          c <- list $ symbols \\ set [a,b],
          d <- list $ symbols \\ set [a,b,c],
          e <- list $ symbols \\ set [a,b,c,d],
          f <- list $ symbols \\ set [a,b,c,d,e],
          g <- list $ symbols \\ set [a,b,c,d,e,f],
          h <- list $ symbols \\ set [a,b,c,d,e,f,g],
          i <- list $ symbols \\ set [a,b,c,d,e,f,g,h],
          j <- list $ symbols \\ set [a,b,c,d,e,f,g,h,i] ]  

solution =
    concat $ Prelude.map show p
    where p = perms !! 999999

main = print solution

