#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif



void solve(){
	int a[3][3] ;
	for(int i= 0 ; i < 3 ; i++){
		for(int j = 0 ; j <3 ; j++){
			cin >> a[i][j] ;
		}
	}
	set<vector<int>> st ;
	for(int i = 0 ; i < 3 ; i++){
		vi x ;
		for(int j = 0 ; j < 3 ; j++){
			x.pb(a[i][j]) ;
		}
		st.insert(x) ;
	}
	for(int j = 0 ; j < 3 ; j++){
		vi x ;
		for(int i = 0 ; i < 3 ; i++){
			x.pb(a[i][j]) ;
		}
		st.insert(x) ;
	}
	vi x ;
	for(int i = 0 ; i < 3 ; i++){
		x.pb(a[i][i]) ;
	}
	st.insert(x) ;
	x.clear() ;
	x.pb(a[0][2]) ; x.pb(a[1][1]) ; x.pb(a[2][0]) ;
	st.insert(x) ;
	int n  ;
	cin >> n ;
	int b[n] ;
	for(int i = 0 ; i < n ; i++){
		cin >> b[i] ;
	}	
	for(int i = 0 ; i < (1<<n) ; i++){
		if(__builtin_popcountll(i) == 3){
			vi nx ;
			for(int j = 0 ; j < n ; j++){
				if((1LL << j) & i){
					nx.pb(b[j]) ;
				}
			}
			set<int> v ;
			for(int x : nx) v.insert(x) ;
			//trace(v) ;
			for(auto x : st){
				set<int> n_set ;
				for(int z : x){
					n_set.insert(z) ;
				}
				if(v == n_set){
					cout << "Yes\n" ;
					return ;
				}
			}	
		}
	}
	cout << "No\n" ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 256