function main(string) {
  const arr = string.split(' ');
  const firstLastStr = function(str) {
    return {'first': str.slice(0,1), 'last': str.slice(-1)};
  }
  const siritori = ((firstLastStr(arr[0]).last === firstLastStr(arr[1]).first) && (firstLastStr(arr[1]).last === firstLastStr(arr[2]).first));
  console.log(siritori ? 'YES' : 'NO');
}

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