#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...)                                         \
  GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
  (__VA_ARGS__)
#define INPUTARR(n, a) \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
template <class T>
void DEBUGARR(const T* const t, const ll size) {}
template <class T>
void DEBUGARRL(const T* const t, const ll size) {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
template <class T>
void DEBUGARR(const T* const t, const ll size) {
  DEBUG("ARRAY size:", size);
  PRINTa(t, size);
}
template <class T>
void DEBUGARRL(const T* const t, const ll size) {
  DEBUG("ARRAY size:", size);
  PRINTal(t, size);
}
#endif
#ifdef ANS
#else
#endif
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  //solve
  INPUTARR(9,a);
  INPUT(n);
  INPUTARR(n,b);
  bool t[9];
  REP(i,9){
    t[i]=false;
    REP(j,n){
      if(b[j]==a[i]){
        t[i]=true;
        break;
      }
    }
  }
  //row
  REP(i,3){
    if(t[i*3]&&t[i*3+1]&&t[i*3+2]){
    PRINT("Yes");
    return;}
  }
  DEBUG();
  //col
  REP(i,3){
    if(t[i]&&t[i+3]&&t[i+6]){
      PRINT("Yes");
      return;
    }
  }
  //diag
  if(t[4]&&((t[0]&&t[8])||(t[2]&&t[6]))){
    PRINT("Yes");
    return;
  }
  PRINT("No");

  return;
}

Measured memory_bytes: 256