#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
using namespace std;
bool check(string x, string y) {
  int a = x.size()-1;
  return x[a] == y[0];
}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if(check(a, b) && check(b, c)) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

#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;
}