#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a[3][3];
  	for (int i=0 ; i < 3; i++){
      for(int j = 0; j < 3 ; j++){
        cin >> a[i][j];
      }
    }
  int N;
  cin >> N;
  
  bool b[3][3];
  int x;
  for (int i=0 ; i < 3; i++){
      for(int j = 0; j < 3 ; j++){
        cin >> x;
        if(a[i][j]==x)
          b[i][j] = true;
        else
          b[i][j] = false;
      }
    }
  
  string answer = "No";
  bool  judge = true;
  for (int j = 0; j < 3; j++){
 	for (int i = 0; i<3; i++){
    	judge = (judge == b[i][j])
  	}
    if(judge == true)
      answer = "Yes";
  }
  judge = true;
  
  for (int  j = 0; j < 3; j++){
 	for (int i = 0; i<3; i++){
    	judge = (judge == b[j][i])
  	}
    if(judge == true)
      answer = "Yes";
  }
   
  if(b[0][0] && b[1][1] && b[2][2])
    answer = "Yes";
  
  if(b[0][2] && b[1][1] && b[2][0])
    answer  = "Yes";
  cout << answer << endl;
}