"use strict";
const Main = function(input){
	let xs = input.trim().split(' ');
    let z = xs[1].split('');
    let a = xs[0].split('').reverse();
    let b = xs[1].split('').reverse();
    let c = xs[2].split('');
    
    if(a[0] == z[0] && b[0] == c[0]){
      console.log('YES');
    }else{
      console.log('NO');
    }
  
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));