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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    string a, b, c; cin>>a>>b>>c;
    int size_a = a.size(), size_b = b.size();
    cout<<(a[size_a-1] == b[0] && b[size_b-1] == c[0] ?  "YES" : "NO")<<endl; 
}

int main(){
    solve();
    Bye;
}
#include<stdio.h>

int main(){
	char a[150];
	int x=1;
	scanf("%[^\n]", a);
	for (int i=0 ; a[i]!='\0' ; i++){
		if (a[i]==' '){
			if (a[i-1]==a[i+1]){
				continue;
			} else{
				x=0;
				break;
			}
		}
	}
	printf("%s\n", x==1 ? "YES" : "NO");
	return 0;
}