open Printf
open Scanf

let () =
  let shiritori a b c =
    if a.[String.length a - 1] = b.[0] && b.[String.length b - 1] = c.[0] then "YES" else "NO" in
  let a, b, c = scanf "%s %s %s\n" (fun x y z -> (x, y, z)) in
  shiritori a b c |> printf "%s\n"
