function main(input) {
  input=input.trim();
  const a = input.split(" ")[0];
  const b = input.split(" ")[1];
  const c = input.split(" ")[2];
  if(a.substr(a.length-1,1)==b.substr(0,1)&&b.substr(b.length-1,1)==c.substr(0,1)){
    console.log("YES");
  }else{
    console.log("NO");
  }

}



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