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