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>
namespace Program {
using namespace std;
class Solver {
 private:
  int N;
  int W;
  array<long long int, 100> v;
  array<long long int, 100> w;

 public:
  Solver() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> W;
    int overN = 0;
    int tmpw, tmpv;
    cin >> tmpw >> tmpv;
    for (int i = 1; i <= N; i++) {
      if (W < tmpw)
        overN++;
      else {
        w[i - overN - 1] = tmpw;
        v[i - overN - 1] = tmpv;
      }
      if (i == N) break;
      cin >> tmpw >> tmpv;
    }
    N = N - overN;
  }
  void Solve() { cout << knapsackW(w, v, N, W) << endl; }
  long long int knapsackW(const array<long long int, 100> &w,
                          const array<long long int, 100> &v,
                          const long long int &numOfItems,
                          const long long int &wUpperBound) {
    array<array<long long int, 10000>, 100> dp;
    long long int j;
    for (long i = 0; i < N; i++) dp[i].fill(0);
    for (long i = 0; i < numOfItems; i++) {
      for (j = 0; j <= wUpperBound; j++) {
        if (w[i] <= j && dp[i][j] < dp[i][j - w[i]] + v[i]) {
          dp[i + 1][j] = dp[i][j - w[i]] + v[i];
        } else {
          dp[i + 1][j] = dp[i][j];
        }
      }
    }
    return N == 0 ? 0 : dp[numOfItems][wUpperBound];
  }
};
}  // namespace Program
int main() {
  void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
  Program::Solver obj;
  (obj.*pSolve)();
  return 0;
}
