function Main(input) {
  const words = input.split(' ');
  const a = words[0];
  const b = words[1];
  const c = words[2];

  if(b.startsWith(a.slice(-1)) && c.startsWith(b.slice(-1))) {
    console.log('YES');
  } else {
    console.log('NO')
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));