#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

ll combination(ll n, ll r) {
    ll nf = 1, rf = 1;
    if (r * 2 > n) r = n - r;
    for (ll i = 1; i <= r; ++i) {
        nf = ((n - r + i) * nf) % MOD;
        rf = (i * rf) % MOD;
    }

    return (nf / rf);
}

ll kaijo(ll a) {
    ll ans = 1;
    for (ll i = 2; i <= a; ++i) {
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

ll kaijo2(ll n, ll a) {
    ll ans = 1;
    for (ll i = 0; i < a; ++i) {
        ans *= (n - i);
        ans %= MOD;
    }

    return ans;
}

ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int main(void) {
    vector<int> aa(9, 0);
    vector<int> bb(9, 0);
    rep (i, 0, 9) {
        int ab;
        cin >> ab;
        aa[i] = ab;
    }

    cin >> n;

    rep (i, 0, n) {
        int ab;
        cin >> ab;
        bb[i] = ab;
    }

    if (find(bb.begin(), bb.end(), aa[0]) != bb.end() && find(bb.begin(), bb.end(), aa[1]) != bb.end() && find(bb.begin(), bb.end(), aa[2]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[3]) != bb.end() && find(bb.begin(), bb.end(), aa[4]) != bb.end() && find(bb.begin(), bb.end(), aa[5]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[6]) != bb.end() && find(bb.begin(), bb.end(), aa[7]) != bb.end() && find(bb.begin(), bb.end(), aa[8]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[0]) != bb.end() && find(bb.begin(), bb.end(), aa[3]) != bb.end() && find(bb.begin(), bb.end(), aa[6]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[1]) != bb.end() && find(bb.begin(), bb.end(), aa[4]) != bb.end() && find(bb.begin(), bb.end(), aa[7]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[2]) != bb.end() && find(bb.begin(), bb.end(), aa[5]) != bb.end() && find(bb.begin(), bb.end(), aa[8]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[0]) != bb.end() && find(bb.begin(), bb.end(), aa[4]) != bb.end() && find(bb.begin(), bb.end(), aa[8]) != bb.end()) cout << "Yes" << endl;
    else if (find(bb.begin(), bb.end(), aa[2]) != bb.end() && find(bb.begin(), bb.end(), aa[4]) != bb.end() && find(bb.begin(), bb.end(), aa[6]) != bb.end()) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256