let last s = s.[(String.length s) - 1];;
let first s = s.[0];;
let isShiritori a b c = if (last a=first b && last b=first c) then "YES" else "NO";;
Scanf.scanf "%s %s %s" isShiritori
|> Printf.printf "%s\n"