import Control.Monad

main = do
  [str1, str2, str3] <- sequence [getLine, getLine, getLine]
  let a1 = map read (words str1) ::[Int]
  let a2 = map read (words str2) ::[Int]
  let a3 = map read (words str3) ::[Int]
  str <- getLine
  let n = read str ::Int
  bs <- forM [1..n] $ \i -> do
    str <- getLine
    let b = read str ::Int
    return b
  let ans1 = map (`elem` bs) a1
  let ans2 = map (`elem` bs) a2
  let ans3 = map (`elem` bs) a3
  if ck ans1 ans2 ans3 == True
    then putStrLn "Yes"
    else putStrLn "No"


ck :: [Bool] -> [Bool] -> [Bool] -> Bool
ck lt1 lt2 lt3
  | and lt1 == True = True
  | and lt2 == True = True
  | and lt3 == True = True
  | and [lt1 !! 0, lt2 !! 0, lt3 !! 0] == True = True
  | and [lt1 !! 1, lt2 !! 1, lt3 !! 1] == True = True
  | and [lt1 !! 2, lt2 !! 2, lt3 !! 2] == True = True
  | and [lt1 !! 0, lt2 !! 1, lt3 !! 2] == True = True
  | and [lt1 !! 2, lt2 !! 1, lt3 !! 0] == True = True
  | otherwise = False
  