#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

class LazySegTree {
public:
    int p = 2;
    vector<int> node, lazy;
    vector<bool> islazy;
    LazySegTree(vector<int> &A) {
        while (A.size() > p) p *= 2;
        node = vector<int>(2*p-1,INF);
        lazy = vector<int>(2*p-1,INF);
        islazy = vector<bool>(2*p-1,false);

        for (int i = 0;i < A.size();i++) {
            node[p-1+i] = A[i];
        }
        for (int i = p - 2;i >= 0;i--) {
            node[i] = min(node[i*2+1],node[i*2+2]);
        }
    }

    void eval(int k, int l, int r) {
        //値の伝播
        if (islazy[k]) {
            node[k] = min(node[k],lazy[k]);
            if (r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                islazy[k*2+1] = islazy[k*2+1] = true;
            }
            islazy[k] = false;
            lazy[k] = INF;
        }
    }

    void update(int L, int R, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = p;
        //k番ノードに遅延評価
        eval(k, l, r);
        if (R <= l || r <= L) return;
        if (L <= l && r <= R) {
            islazy[k] = true;
            lazy[k] = min(lazy[k],x);
            eval(k,l,r);
        }
        else {
            update(L, R, x, 2*k+1, l, (l+r)/2);
            update(L, R, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }
 
    int getval(int start,int end,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = p;
        if (start <= l && r <= end) {return node[k];}
        if (r <= start || end <= l) {return INF;}
        int L,R;
        L = getval(start,end,k*2+1,l,(l+r)/2);
        R = getval(start,end,k*2+2,(l+r)/2,r);
        return {min(L,R)};
    }
};

bool solve() {
	string a,b,c;cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256