inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = inp.shift()
B = inp.shift()
C = inp.shift()
console.log(A[A.length - 1] == B[0] && B[B.length - 1] == C[0] ? 'YES' : 'NO')