"use strict";

function main(input){
  const args = input.trim().split(' ');
  const a = args[0].split('').reverse()[0] == args[1][0];
  const b = args[1].split('').reverse()[0] == args[2][0];
  console.log(a && b ? "YES" : "NO");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  