#include <stdio.h>
#include <string.h>

int main (){
	char a[100];
	char b[100];
	char c[100];
	scanf("%s %s %s", a, b, c);
	
	int A = strlen(a);
	int B = strlen (b);
	
	for (int i = 0; i < 10; i++){
		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){
			puts ("YES");
			break;
		}
		else{
			puts ("NO");
			break;
		}
	}
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int,string>;

int main() {
  string a,b,c;
  cin >> a >> b >>c ;
  if(a.back() == b.front() && b.back() == c.front()) cout <<"YES" << endl;
  else cout << "NO" << endl;
}