#include <iostream>
#include <string>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
		cout << "YES";
	else
		cout << "NO";
}
#include<bits/stdc++.h>
using namespace std;
int main() {
	bool A=0;
	char ch,ch_;
	cin>>ch;
	ch_=ch;
	while((cin>>ch)!=0) {
		if(ch_=='A'&&ch=='C') {
			cout<<"Yes";
			return 0;
		}
		ch_=ch;
	}
	cout<<"No";
	return 0;
}