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>
std::string IntToString(long long a) {
  char x[100];
  sprintf(x, "%lld", a);
  std::string s = x;
  return s;
}
long long StringToInt(std::string a) {
  char x[100];
  long long res;
  strcpy(x, a.c_str());
  sscanf(x, "%lld", &res);
  return res;
}
inline void printIntVal(long long a) {
  std::cout << "The Value is: " << IntToString(a) << std::endl;
}
inline void printStringVal(std::string a) {
  std::cout << "The Value is: " << a << std::endl;
}
inline std::string GetString() {
  char x[1000005];
  scanf("%s", x);
  std::string s = x;
  return s;
}
inline std::string uppercase(std::string s) {
  int n = (int)s.size();
  for (int i = 0; i < n; i++)
    if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline std::string lowercase(std::string s) {
  int n = (int)s.size();
  ;
  for (int i = 0; i < n; i++)
    if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN(std::string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
inline long long CharToInt(char c) { return (c - '0'); }
int main() {
  std::string a = GetString();
  std::string b = GetString();
  std::string c = GetString();
  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}
