import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in);
    val a, b, c = sc.next();
    if(a.last == b.head && b.last == c.head) {
      System.out.println("YES")
    } else {
      System.out.println("NO")
    }
  }
}
