'use strict'

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