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;
const int N = 105;
map<int, int> dp[N];
int n, m, ans;
int v[N], w[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", w + i, v + i);
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (map<int, int>::iterator it = dp[i].begin(); it != dp[i].end(); it++) {
      int V = (*it).second;
      int W = (*it).first;
      dp[i + 1][W] = max(dp[i + 1][W], V);
      if (W + w[i + 1] <= m)
        dp[i + 1][W + w[i + 1]] = max(dp[i + 1][W + w[i]], V + v[i + 1]);
    }
  for (map<int, int>::iterator it = dp[n].begin(); it != dp[n].end(); it++) {
    int W = (*it).first;
    int V = (*it).second;
    if (W <= m) ans = max(ans, V);
  }
  printf("%d\n", ans);
  return 0;
}
