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;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const int INF = numeric_limits<int>::infinity();
void printa() { cout << "\n"; }
template <class T, class... A>
void printa(const T &first, const A &...rest) {
  cout << first;
  printa(rest...);
}
template <class... A>
void printa(const A &...rest) {
  printa(rest...);
}
void prints() { cout << " "; }
template <class T, class... A>
void prints(const T &first, const A &...rest) {
  cout << first;
  prints(rest...);
}
template <class... A>
void prints(const A &...rest) {
  prints(rest...);
}
int factorial(int x) {
  int f = 1;
  for (int i = 1; i < x + 1; i++) f = f * i;
  return f;
}
int sigma(int x) {
  int s;
  for (int i = 1; i < x + 1; i++) s = s + i;
  return s;
}
int middle(int x) {
  if (x % 2 == 0)
    return x / 2;
  else
    return x / 2 + 1;
}
double heron(int a, int b, int c) {
  double s;
  s = (a + b + c) / 2;
  return sqrt(s * (s - a) * (s - b) * (s - c));
}
double trapezium(int a, int b, int h) { return (a + b) * h / 2; }
double triangle(int a, int h) { return a * h / 2; }
void sorm(vector<int> vec) { sort(vec.begin(), vec.end()); }
void sorg(vector<int> vec) { sort(vec.begin(), vec.end(), greater<int>()); }
int cmp(const void *p, const void *q) {
  if (*(double *)p > *(double *)q) return 1;
  if (*(double *)p < *(double *)q) return -1;
  return 0;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string st, tt, nt;
  cin >> st >> tt >> nt;
  if (st.end() == tt.begin() && tt.end() == nt.begin())
    printa("YES");
  else
    printa("NO");
  return 0;
}
