function main(input) {
   input = input.trim();
  const a = input.split(" ");
 console.log(a[0].charAt(a[0].length-1)==a[1].charAt(0)&&a[1].charAt(a[1].length-1)==a[2].charAt(0)?"YES":"NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));