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

int main(){
	char A[11], B[11], C[11];
	scanf("%s  %s  %s", A, B, C);
	
	if (A[strlen(A) - 1] == B [0] && B[strlen(B) - 1]  == C [0]){
		printf ("YES\n");
	}
	else {
		printf ("NO\n");
	}
	
	return 0; 
}
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	vector<string> a(3);

	string res = "YES";
	for (ll i = 0; i < 3; i++)
	{
		cin >> a[i];

		if (i > 0)
		{
			if (a[i - 1].back() != a[i].front())
			{
				res = "NO";
			}
		}
	}

	println(res);
}
