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;
typedef struct edge_ {
  long long to;
  long long cost;
} edge;
constexpr double PI = 3.14159265358979323846;
constexpr long long INF = 1 << 15;
constexpr long long MOD = (long long)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy4[4] = {0, 1, 0, -1};
constexpr int dx4[4] = {1, 0, -1, 0};
constexpr int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  for (const T& x : vec) os << x << " ";
  return os;
}
template <typename S, typename T>
istream& operator>>(istream& is, pair<S, T>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  os << "{" << p.first << " " << p.second << "}";
  return os;
}
template <typename T>
void say(vector<T>& vec, string pad = " ") {
  for (const T& elem : vec) cout << elem << pad;
}
int main() {
  vector<string> s(3);
  cin >> s;
  ((s[0][s[0].length() - 1] == s[1][0] && s[1][s[1].length()] == s[2][0])
       ? (cout << "YES" << endl)
       : (cout << "NO" << endl));
  return 0;
}
