#include <bits/stdc++.h>
typedef struct s_Bingo {
  int map[3][3];
  int map_01[3][3];
  int hint_num;
  int hint[100];
} t_Bingo;
int input_map(t_Bingo *bingop) {
  int i = 0;
  while (i < 3) {
    scanf("%d %d %d", &bingop->map[i][0], &bingop->map[i][1],
          &bingop->map[i][2]);
    i++;
  }
  return (0);
}
int input_hint(t_Bingo *bingop) {
  int i;
  scanf("%d", &i);
  bingop->hint_num = i;
  while (i > 0) {
    i--;
    scanf("%d", &bingop->hint[i]);
  }
}
int set_map01(t_Bingo *bingop) {
  int i = 0;
  int j = 0;
  int k = 0;
  while (i < 3) {
    j = 0;
    while (j < 3) {
      k = 0;
      while (k < bingop->hint_num) {
        printf("set1 map %d %d %d\n", i, j, bingop->map[i][j]);
        printf("set2 hint %d %d\n", k, bingop->hint[k]);
        if (bingop->map[i][j] == bingop->hint[k]) {
          bingop->map_01[i][j] = 1;
        } else {
          bingop->map_01[i][j] = 0;
        }
        k++;
      }
      j++;
    }
    i++;
  }
  return (0);
}
int check(t_Bingo *bingop) {
  int i = 0;
  while (i < 3) {
    if ((bingop->map_01[i][0] == 1) &&
        bingop->map_01[i][0] == bingop->map_01[i][1] &&
        bingop->map_01[i][0] == bingop->map_01[i][2])
      return (1);
    i++;
  }
  i = 0;
  while (i < 3) {
    if ((bingop->map_01[0][i] == 1) &&
        bingop->map_01[0][i] == bingop->map_01[1][i] &&
        bingop->map_01[0][i] == bingop->map_01[2][i])
      return (1);
    i++;
  }
  if ((bingop->map_01[0][0] == 1) &&
      bingop->map_01[0][0] == bingop->map_01[1][1] &&
      bingop->map_01[0][0] == bingop->map_01[2][2])
    return (1);
  if ((bingop->map_01[0][2] == 1) &&
      bingop->map_01[0][2] == bingop->map_01[1][i] &&
      bingop->map_01[0][2] == bingop->map_01[2][0])
    return (1);
  return (0);
}
int main() {
  t_Bingo bingo, *bingop;
  int ret;
  int ans;
  bingop = &bingo;
  ret = input_map(bingop);
  ret = input_hint(bingop);
  ret = set_map01(bingop);
  ans = check(bingop);
  if (ans = 1)
    printf("YES");
  else
    printf("NO");
  return (0);
}
