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;
int N, W, sn;
long long res = 0;
map<int, vector<int>> w;
int dp[100000000] = {0};
int main() {
  scanf("%d%d", &N, &W);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (i == 0) sn = a;
    w[a].push_back(b);
  }
  for (auto it = w.begin(); it != w.end(); it++)
    sort(it->second.begin(), it->second.end(), greater<int>());
  if (sn < 10) {
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for (auto it = w.begin(); it != w.end(); it++) {
      for (auto i = it->second.begin(); i != it->second.end(); i++) {
        for (int j = min(W, (sn + 3) * N) - it->first; j >= 0; j--) {
          if (dp[j] >= 0)
            dp[j + it->first] = max(dp[j] + *i, dp[j + it->first]);
          res = max(res, 1LL * dp[j + it->first]);
        }
      }
    }
  } else {
    long long nw = 0;
    while (1) {
      bool up = false;
      auto upb = w.begin();
      for (auto it = w.begin(); it != w.end(); it++) {
        if ((nw + it->first) <= W) {
          if (!up || *(upb->second.begin()) < *(it->second.begin())) upb = it;
          up = true;
        }
      }
      if (!up) break;
      res += *(upb->second.begin());
      nw += upb->first;
      upb->second.erase(upb->second.begin());
    }
  }
  cout << res << endl;
}
