import Data.List (permutations)
import Control.Monad (guard)

dinesman :: [(Int,Int,Int,Int,Int)]
dinesman = do
  
  

  
  
  [baker, cooper, fletcher, miller, smith] <- permutations [1..5]

  
  guard $ baker /= 5

  
  guard $ cooper /= 1

  
  guard $ fletcher /= 5 && fletcher /= 1

  
  guard $ miller > cooper

  
  guard $ abs (smith - fletcher) /= 1

  
  guard $ abs (fletcher - cooper) /= 1

  
  return (baker, cooper, fletcher, miller, smith)

main :: IO ()
main = do
  print $ head dinesman 
  print dinesman