function Main(inputs) {
  var board = inputs.replace(/\n/g,' ').split(/ /).slice(0,9).map(v=>+v)
  var vals = inputs.split('\n').slice(4).map(v=>+v).filter(v=>v>0)

  var rb = vals.reduce((board,val)=>{
    return board.map(v=> v == val ? 'x' : v)
  },board)

  var bingo = 0;

  [rb[0],rb[1],rb[2]].every(v=>v=='x') && bingo++;
  [rb[3],rb[4],rb[5]].every(v=>v=='x') && bingo++;
  [rb[6],rb[7],rb[8]].every(v=>v=='x') && bingo++;

  [rb[0],rb[3],rb[6]].every(v=>v=='x') && bingo++;
  [rb[1],rb[4],rb[7]].every(v=>v=='x') && bingo++;
  [rb[2],rb[5],rb[8]].every(v=>v=='x') && bingo++;

  [rb[0],rb[4],rb[8]].every(v=>v=='x') && bingo++;
  [rb[2],rb[4],rb[6]].every(v=>v=='x') && bingo++;

  //console.log(rb.join(' ').replace(/(([^ ]+ ){3})/g,'$1\n'))
  //console.log({bingo})
  console.log(bingo > 0 ? 'Yes' : 'No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

