#include<bits/stdc++.h>
using namespace std;

int main(){

 string a,b,c;
 cin >> a >> b >> c;

 int A, B, C;
  A = a.size()-1;
  B = b.size()-1;
  C = c.size()-1;
  
  if(a.at(A)==b.at(0)&& b.at(B)==c.at(0))
 	cout << "YES" <<endl;
  else
    cout <<"NO" <<endl;
}
#include <stdio.h>

int main(){
	char arr[355];
	scanf("%[^\n]", &arr);
	int test = 1;
	for(int i=0;arr[i]!='\0';i++){
		if(arr[i]==' '&&arr[i-1]!=arr[i+1]){
			test=0;
			break;
		}
	}
	if(test==1){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}