{-# LANGUAGE OverloadedStrings #-}
import Data.Char
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  as <- concat <$> replicateM 3 (parseLine <$> BS.getLine)
  n <- head.parseLine <$> BS.getLine
  bs <- concat <$> replicateM n (parseLine <$> BS.getLine)
  BS.putStrLn . BS.pack $ if solve as bs then "Yes" else "No"
  where
     parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)

solve :: [Int] -> [Int] -> Bool
solve as bs = bingo (map (`elem` bs) as)

bingo :: [Bool] -> Bool
bingo xs = or . map (and . map (xs !!)) $ rows
  where
    rows = [
      [0,1,2]
     ,[3,4,5]
     ,[6,7,8]
     ,[0,3,6]
     ,[1,4,7]
     ,[2,5,8]
     ,[0,4,8]
     ,[2,4,6]
     ]