#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char a[20], b[20], c[20];
  cin >> a >> b >> c;
  int x=strlen(a);
  int y=strlen(b);
  int z=strlen(c);
  if(a[x-1]==b[0]){
    if(b[y-1]==c[0]){
      cout << "YES\n";
    }
    else cout << "NO\n";
  }
  else cout << "NO\n";

}
  
