#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s, s1, s2;
    cin >> s >> s1 >> s2;
    int n = s.size(), m = s1.size();
    if( s[n - 1] == s1[0] && s1[m - 1] == s2[0] )
    {
        cout << "YES";
    }
    else
        cout << "NO";
}
