import Data.Bool
import Data.List
import Data.Maybe
import Data.Vector.Generic ((!))
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

main = interact $ sub . lines

sub (l1:l2:l3:ls) = sol v bs
  where
  v = V.fromListN 3 $ V.fromListN 3 . fmap (read::String->Int) . words <$> [l1,l2,l3]
  bs = fmap read $ tail ls :: [Int]

sol v bs = bool "No" "Yes" . bingo $ V.map (\u -> foldl' mark u bs) v

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

mark u b = maybe u (\i -> V.modify (\w -> VM.write w i 0) u) $ V.findIndex (==b) u