main=do
 aa<-getLine
 ab<-getLine
 ac<-getLine
 let a=words$aa++" "++ab++" "++ac
 getLine
 b<-lines<$>getContents
 putStrLn$if length(filter(\ls->f b(map(\id->a!!id)ls))[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]])==0 then"No"else"Yes"
f b[]=True
f b(a:as)=if a`elem`b then f b as else False
