You are given three strings A, B and C. Check whether they form a word chain.

More formally, determine whether both of the following are true:

* The last character in A and the initial character in B are the same.
* The last character in B and the initial character in C are the same.



If both are true, print `YES`. Otherwise, print `NO`.

Constraints

* A, B and C are all composed of lowercase English letters (`a` - `z`).
* 1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.

Input

Input is given from Standard Input in the following format:


A B C


Output

Print `YES` or `NO`.

Examples

Input

rng gorilla apple


Output

YES


Input

yakiniku unagi sushi


Output

NO


Input

a a a


Output

YES


Input

aaaaaaaaab aaaaaaaaaa aaaaaaaaab


Output

NO
#include <bits/stdc++.h>
using namespace std;
bool sBs(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long Powb(long long b, long long n, long long m);
long long BS(vector<pair<long long, long long> > &PS, long long s, long long e,
             long long ser);
long long MI(long long a, long long m);
long long P[101LL + 1];
void Sieve(int n = 101LL);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long q = 1, t;
  while (q--) {
    long long i, j, n, m, k, l = 0, r = 0, a = 1, b = 0, c = 0, d = 0, e, g = 1,
                             p, u, v, w, x, y, flag = 1;
    string s1, s2, s3;
    cin >> s2 >> s2 >> s3;
    n = s1.size();
    m = s2.size();
    d = s3.size();
    if (s1[n - 1] == s2[0] and s2[m - 1] == s3[0])
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
long long Powb(long long b, long long n, long long m) {
  if (n == 0) return 1LL;
  if (n == 1) return b;
  long long temp = Powb(b, n / 2, m);
  if (n % 2 == 0) {
    return (temp * temp) % m;
  } else {
    return (b * ((temp * temp) % m)) % m;
  }
}
long long BS(vector<pair<long long, long long> > &PS, long long s, long long e,
             long long ser) {
  if (s > e) return s;
  long long mid = (s + e) / 2;
  if (PS[mid].first == ser) {
    return mid;
  } else if (PS[mid].first > ser) {
    return BS(PS, s, mid - 1, ser);
  } else
    return BS(PS, mid + 1, e, ser);
}
long long MI(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
void Sieve(int n) {
  for (int i = 1; i <= n; i++) P[i] = i;
  for (long long i = 2; i * i <= n; i++) {
    if (P[i] == i) {
      for (long long j = i * i; j <= n; j += i) {
        if (P[j] == j) P[j] = i;
      }
    }
  }
}
