import Data.List import Data.Bool import Data.Maybe main = do as <- map read . words <$> getContents let ias = zip ([1..15]++[0]) as putStrLn $ bool "No" "Yes" (sim 0 ias) sim c ias | all (uncurry (==)) ias = True | otherwise = maybe False (\(i,_) -> sim i (delete (fromJust next) ias)) next where next = find (\(_,a) -> a == c) ias