import Control.Applicative ((<$>)) import Control.Monad (replicateM) import Data.Vector.Unboxed (Vector, (!), (//)) import qualified Data.Vector.Unboxed as V main :: IO () main = solve <$> replicateM 4 (map read <$> words <$> getLine) >>= putStrLn solve :: [[Int]] -> String solve xss = f (bd, ix0) where bd = V.fromList $ concat xss :: Vector Int gl = V.fromList $ [1..15] ++ [0] :: Vector Int (Just ix0) = V.findIndex (== 0) bd nbi i = [4 * u' + v'| let (u, v) = divMod i 4, (u', v') <- [(u+1,v),(u-1,v),(u,v+1),(u,v-1)], u' >= 0 && u' <= 3 && v' >= 0 && v' <= 3] f (b, i) | b == gl = "Yes" | otherwise = case filter ((== (i+1)) . (b !)) (nbi i) of [j] -> f (b // [(i,i+1),(j,0)] , j) _ -> "No"