import std.stdio,std.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array,std.numeric;
 
T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?e[1..$]:[];return tp;}}
struct Stack(T){T[]e;auto push(T t){e~=t;}auto push(T[]ts){e~=ts;}T pop(){T tp=e[$-1];e=e.length>1?e[0..$-1]:[];return tp;}}
 
//END OF TEMPLATE

void main(){
    long[] [long] card;
    bool[9] panch;
    3.iota.each!((i){
            auto a=readarr;
            3.iota.each!(j=>card[a[j]]~=i*3+j);
            }); 
    long n;
    n.scan;
    auto b=n.iota.map!(i=>readln.chomp.to!long);
    foreach(x;b){
        if(x in card)
            card[x].each!(i=>panch[i]=true);
    }   
    auto lines=3.iota.map!(r=>3.iota.map!(c=>panch[r*3+c]).array).array;
    lines~=3.iota.map!(c=>3.iota.map!(r=>panch[r+c*3]).array).array;
    lines~=3.iota.map!(x=>panch[x*3+2-x]).array;
    lines~=3.iota.map!(x=>panch[x*3+x]).array;
    (lines.filter!(l=>l==[true,true,true]).array.length>0?"Yes":"No").writeln;
}
