'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = args[0][0]
	const b = args[0][1]
	const c = args[0][2]
	if (a[a.length - 1] === b[0] && b[b.length - 1] === c[0]) console.log('YES')
	else console.log('NO')
}

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