import Data.Bool
import Data.Vector.Generic ((!))
import qualified Data.Vector as V

main = interact $ sol . lines

sol as = bool "No" "Yes" $ bingo v
  where
  v = V.fromList $ V.fromList . fmap (`elem` bs) . words <$> take 3 as
  bs = words . unwords $ drop 4 as

bingo v = V.any V.and v
  || any (\j -> V.all (!j) v) [0..2]
  || all (\i -> v!i!i) [0..2]
  || all (\i -> v!i!(2-i)) [0..2]