import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    a <- replicateM 3 $ unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine
    n <- fst . fromJust . BS8.readInteger <$> BS8.getLine
    b <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getContents
    
    let l = map (map (\i -> elem i b)) a
    
    print l

    putStrLn $ if (any id $ map (all id) l) || (any id $ map (all id) $ transpose l) || (all id [(l !! x) !! x | x <- [0..2]]) || (all id [(l !! x) !! (2 - x) | x <- [0..2]]) then "Yes" else "No"
