import Data.Maybe
import Data.List

main = do
 a1 <- map (read::String->Int) . words<$> getLine 
 a2 <- map (read::String->Int) . words<$> getLine 
 a3 <- map (read::String->Int) . words<$> getLine 
 _ <- (read::String->Int) <$> getLine
 bb <- map (read::String->Int) . lines <$>getContents
 let aa = concat[a1,a2,a3]
 let indexies = map (1+) .catMaybes $ map (f aa) bb
 --print indexies
 if g indexies then putStr "Yes" else putStr "No"


f :: [Int] -> Int  -> Maybe Int
f aa x = findIndex (x==) aa

g :: [Int] -> Bool
--g indexies = all $ map (-1>) [1,2,3] 
g indexies = or [and $ map (elem_ indexies) [1,2,3] , 
	  and $map (elem_ indexies) [4,5,6] ,
      and $map (elem_ indexies) [7,8,9] ,
      and $map (elem_ indexies) [1,5,9] ,
      and $map (elem_ indexies) [3,5,7] ,
      and $map (elem_ indexies) [1,4,7] ,
      and $map (elem_ indexies) [2,5,8] ,
      and $map (elem_ indexies) [3,6,9] ]
      
elem_ :: [Int] -> Int -> Bool
elem_ x y = elem y x