#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int a[10];
  for (int i = 0; i < 10; ++i) {
    cin >> a[i];
  }
  int n; 
  for (int i = 0; i < n; ++i) {
    int s;
    cin >> s;
    if (a[i] == s) a[i] = 0;
  }
  if (a[0] + a[1] + a[2] = 0 || a[3] + a[4] + a[5] = 0 || a[6] + a[7] + a[8] = 0 ||
      a[2] + a[5] + a[8] = 0 || a[1] + a[4] + a[7] = 0 || a[0] + a[3] + a[6] = 0 ||
      a[0] + a[4] + a[8] = 0) {
    cout << "Yes" << "\n";
  } else cout << "No" << "\n";
  return 0;
}
