#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<int>P={2,3,5,7,11,13,17,19,23};
    
    int crtr=1;
    vector<int>A(9);
    for(int i=0;i<9;i++)
    {cin>>A[i];}
    int N;
    cin>>N;
    vector<int>B(N);
    for(int i=0;i<N;i++)
    {cin>>B[i];}
    for(int i=0;i<9;i++)
    {for(int j=0;j<N;j++)
    {if(A[i]==B[j]){crtr*=P[i];}}
        }
    
    if(crtr%30!=0&&
       crtr%1001!=0&&
       crtr%7429!=0&&
       crtr%506!=0&&
       crtr%1495!=0&&
       crtr%627!=0&&
       crtr%238!=0&&
       crtr%935!=0){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
    
