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;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  void unionSet(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  int k = a % b;
  if (k == 1) return 1;
  if (k == 0) return b;
  int ans = gcd(b, k);
  return ans;
}
long long digisum(long long a) {
  int sum = 0;
  while (a) {
    sum += a % 10;
    a /= 10;
  }
  return sum;
}
long long countpow(long long a, long long b) {
  int ans = 0;
  if (b == 0) return -1;
  while (1) {
    if (a % b == 0) {
      a /= b;
      ans++;
    } else
      break;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string x, y, z;
  cin >> x >> y >> z;
  cout << (x[x.size() - 1] == y[0] && y[y.size() - 1] == z[0] ? "Yes" : "No")
       << endl;
}
