'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => n.split(''));

  const a = s[0];
  const b = s[1];
  const c = s[2];

  const a_last  = a[a.length - 1];
  const b_first = b[0];
  const b_last  = b[b.length - 1];
  const c_first = c[0]

  const ans = (a_last === b_first && b_last === c_first) ? 'YES' : 'NO';

  console.log(ans);
}

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