#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,N,M;
  cin>>S>>N>>M;
  if(S.at(S.size()-1)==N.at(0)&&N.at(N.size()-1)==M.at(0)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}