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