import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv;

void main() {
  auto a = readln.split;
  ((a[0][$-1] == a[1][0] && a[1][$-1] == a[2][0]) ? "YES" : "NO").writeln;
}
