// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii         pair<int,int>
#define psi         pair<string,int>
#define vi          vector<int>
#define vpii        vector<pii>
#define vvi         vector<vi>
#define sz(x)       (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n)     fixed<<setprecision(n)
#define ini(a, i)   memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "Yes" : "No")<<endl;
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
    #ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
      ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
      *this << "[";
      for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
      ris << "]";
    }
    #else
    sim dor(const c&) { ris; }
    #endif
};
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
    tezz
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int a[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    int q;
    cin >> q;
    while(q--){
        int k;
        cin >> k;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i][j] == k){
                    a[i][j]=-1;                    
                }
            }
        }
        for(int i=0; i<3; i++){
            int c=0;
            for(int j=0; j<3; j++){
                if(a[i][j]==-1)c++;
            }
            if(c==3){
                output(1);
                return 0;
            }
        }
        for(int j=0; j<3; j++){
            int c=0;
            for(int i=0; i<3; i++){
                if(a[i][j]==-1)c++;
            }
            if(c==3){
                output(1);
                return 0;
            }
        }
        int c=0, d=0;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if((i==j) && a[i][j]==-1)c++;
                if((i+j)==2 && a[i][j]==-1)d++;
            }            
            if(c==3 || d==3){
                output(1);
                return 0;
            }
        }
    }
    output(0);

 
    return 0;
}  

Measured memory_bytes: 3600